Parsing Complex XML File in Java using Dom Parser with heterogenous node structure -


please refer sample xml file

<root> <a id="101"> <b></b> <c id="hello" name="world"> </c> <d id="first d"> </d> </a> <x id="102"> shawn </x> <y id="java world"> </y> <z> cool </z>  <d id="second d"> </d>     </root> 

i want display tag "d" id = "second d" using java dom parser functionality.

please me on this.

first of decide dom-parser library want use. prefer jdom2. there plenty of tutorial in internet. thing have read document (string jdom-document) , doc.getrootelement().getchildtext("d"). of course should error-checkings if read in document null or root element , on. think enough helping job done yourself.

edit: saw xml-file not well-structured can see last line have closing tag closed in same line above.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -