java - In a xml file,How can I get the data in a label depending on another label in the same level of node? -


i have xml file following:

<root> <doc>   <str name="name">test1</str>   <str name="uri">test1.com</str> </doc> <doc>   <str name="name">test2</str>   <str name="uri">test1.com</str> </doc>  </root> 

i want parsing file. name using dom4j.

for(element doc : docs ){           list<element> strs = doc.elements();           for(element str : strs ){               if("name".equals(str.attributevalue("name"))){                  system.out.println(str.gettext());                       }                 }             } 

how can data of 'uri' after getting data of 'name'under same node 'doc'?

thaks lot!

isn't enough following:

for(element doc : docs ){    list<element> strs = doc.elements();    for(element str : strs ){       if("name".equals(str.attributevalue("name"))){          system.out.println(str.gettext());         }       if("uri".equals(str.attributevalue("name"))){          system.out.println(str.gettext());         }    } } 

as you're looping through child of "doc"


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -