开发者

Retrieving XMLs while parsing them

While parsing an XML, given a Node object, can I retrieve the raw XML that corres开发者_Python百科ponds to that Node? I'm using Java and parsing the XML using JDOM.


Element.toString() should return a String representation of the Element but you can also use the XMLOutputter for that purpose (for writing the xml to some outputstream):

Element e=document.getRootElement();
XmlOutputter outputter=new XmlOutputter();
outputter.output(e,System.out);

this simple snippet should write the XML of the root element to stdout.

hope that helped..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜