Hi,
I have an XML file looks like this
<node>
<node2><node3>1</node3></node2>
<node2><node3>2</node3></node2>
<node2><node3>3</node3></node2>
</node>
I am trying to read one child into a string
I want my string to look like that : <node2><node3>1</node3></node2>
File xml = new File("json.txt");
SAXReader reader = new SAXReader();
Document doc = reader.read(xml);
Element root = doc.getRootElement();
for (Iterator i = root.elements().iterator(); i.hasNext();) {
Element elem = (Element) i.next();
Document doc1 = elem.getDocument();
String temp = doc1.asXML();
System.out.println(doc1.asXML());
}
currently temp looks like that
<node>
<node2><node3>1</node3></node2>
<node2><node3>2</node3></node2>
<node2><node3>3</node3></node2>
</node>
but I want temp to look like that
<node2><node3>1</node3></node2>
What am I missing ?