Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the child nodes name?

843834Apr 1 2008 — edited Apr 1 2008
Hi have a XML file, I'm trying to get the child node value but it doesn t work , I'd try different way
in this case I want to get the value "solution"
	DocumentBuilderFactory aronXml = DocumentBuilderFactory.newInstance();
            DocumentBuilder aronText = aronXml.newDocumentBuilder();
            Document aronDoc = aronText.parse (new File("XML/"+listName.get(i)));

String t = aronDoc.getDocumentElement().getNodeName();
            System.out.println ("Root element of the doc is " + t);


NodeList children = aronDoc.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
    Node child = children.item(j);
  
System.out.println(" the first child is: "+child);
     
}
<aaron2 lettres="DEORSU" 
xmlns="com.ingenioquebec.dyna01.dictionnaire"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="com.ingenioquebec.dyna01.dictionnaire laPartieWord.xsd">

	<solution>
		<mot3 mot="DOX"/>
		<mot4 mot="DUVF"/>	
	</solution>
	
	
	<dictionnaire>
		<mot3 mot="DES"/>
		<mot4 mot="DESF"/>
	</dictionnaire>

</aaron2>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2008
Added on Apr 1 2008
7 comments
907 views