xmlファイルの内容をtxtファイルに出力する必要があります。これが私が印刷したいxmlのタイプのサンプルです:
<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>
パスタグを除いて、必要なすべての情報を取得できます...これは私が行ったことです:
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();
それで、私にとって悪魔はどのようにしてそのタグから情報を得るのですか?
PSそれがばかげた質問であるならば、これを忘却に自由に反対票を投じてください...あなたがまた答えに向かって私を導く限り:)
ありがとう