java - How to get nodes of only current element in dom4j? -



java - How to get nodes of only current element in dom4j? -

please help me solve next issue in dom4j

this xml file:

<root> <variant> <name>first</name> <values> <name>first_element</name> </values> </variant> <variant> <name>second</name> <values> <name>second_element</name> </values> </variant> </root>

i used next java code variant node.

root.selectnodes("\root\variant");

this giving me list count 2. using list collect each node individually. list nodes iterating. used next code value "values\name".

variant.selectnodes("\\values\name");

i getting both values "first_element , second_element". 1 help me 1 values of current node.

you should select name current node :

list list = document.selectnodes( "//a/@href" ); (iterator iter = list.iterator(); iter.hasnext(); ) { attribute attribute = (attribute) iter.next(); string url = attribute.getvalue(); }

http://dom4j.sourceforge.net/dom4j-1.6.1/guide.html

java xml dom4j

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -