While parsing an XML, given a Node object, can I retrieve the raw XML that corresponds to that Node? I'm using Java and parsing the XML using JDOM.
+1
A:
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..
smeg4brains
2010-07-23 14:08:42
I don't think that is what the OP means by his question ...
Stephen C
2010-07-23 14:10:48
hmm thats what I wanted. Element.toString() won't work though. It returns [Element: <question/>] (question being my tag). XMLOutputter does the job. I used outputString(Element element) to get the raw XML as a String.
Vijay Dev
2010-07-23 14:30:05