I need to print the contents of an xml file to some txt file. Here is an example of the xml type I want to print:
<log>
<logentry revision="234">
<author>SOMEGUY</author>
<date>SOME DATE</date>
<paths>
<path>asdf/asdf/adsf/asdf.zip</path>
</path>
<msg>blahblahblah</msg>
</logentry>
</log>
I can get all the necessary information except for the path tag ... this is what I did:
FileWriter fstream = new FileWriter("c:\\work\\output.txt");
BufferedWriter out = new BufferedWriter(fstream);
Document document = (Document) builder.build(xmlFile);
Element rootNode = document.getRootElement();
List list = rootNode.getChildren("logentry");
for (int i=0; i< list.size(); i++) {
Element node = (Element) list.get(i);
out.write("Revision: \n" + node.getAttributeValue("revision") + "\n\n");
out.write("Author: \n" + node.getChildText("author") + "\n\n");
out.write("Date: \n" + node.getChildText("date") + "\n\n");
out.write("Message: \n" + node.getChildText("msg"));
out.write("\n-------------------------------------------------"
+"---------------------------------------------------\n\n");
}
out.close();
So how the hell do I get information from this tag?
PS Feel free to lower it to oblivion if this is a stupid question ... while you ALSO direct me to the answer :)
thank
source
share