1

i am having text file called "ecareframework.xml". It contains two request and response. From this file, i have to print request and response separately using string.

public class RequestTime {

    public static void main(String[] args) throws IOException  {

        File xmlFile=new File("C:\\Users\\gsanaulla\\Documents\\My Received Files\\ecarewsframework.xml");

        Reader fileReader = new FileReader(xmlFile);
        BufferedReader bufReader = new BufferedReader(fileReader);
        StringBuffer myStringBuffer = new StringBuffer();
        String line;

        while((line = bufReader.readLine()) != null) {
            if (String.valueOf(line).contains("</S:Envelope>")) { 
                myStringBuffer.append(String.valueOf(line));
            }
            //fileReader.close();
            System.out.println(myStringBuffer.toString());
            }
        bufReader.close();  
        }   
}
Hope
  • 11
  • 3
  • This might help: https://stackoverflow.com/a/1468447/9192223 – hiren Feb 08 '20 at 10:02
  • Thanks Hiren, I need to do this using simple string logic since each time I have to perform this act with separate xml files. – Hope Feb 08 '20 at 10:13
  • I have got the request ,can anyone please suggest or give an idea of how to get specific word from the request. – Hope Feb 08 '20 at 15:18
  • Then you need to parse that XML file (maybe by Xpath) and get your request and response nodes. And then print them. – hiren Feb 10 '20 at 03:37

0 Answers0