on 08-17-2010 12:31 PM
Hi all,
i want to get the parent node of the current node and the not the parent of the parent node.
thank you very much
Could you provide some more details on what you are referring to?
Thanks,
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thanx for your quik replay, now i will give more explanation,
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
<price>4444</price>
<price>3333</price>
<price>1000</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.95</price>
</book>
</bookstore>
now the price with the value 1000, how can get her/his first parent, thanks a lot
Hi
now the price with the value 1000, how can get her/his first parent, thanks a lot
As per my understanding if your prize is 1000 than you need Harry Potter (<title lang="eng">Harry Potter</title>)
that is first node of yor parent node (<book>).
you can use XPATH
"//book[[price='1000']]/title"
Regards,
Manoj Bilthare
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
<fathernode>Harry Potter</fathernode>
<node1>29.99</node1>
<subnode1>29.99</subnode1>
<subnode1-2>29.99</subnode1-2>
<node2>4444</node2>
<node3>3333</node3>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.95</price>
</book>
</bookstore>
the parent node of <subnode1-2>29.99</subnode1-2> is (node1), how can do to get <node1> throw <subnode1-2>29.99</subnode1-2> the sub node of <node1>.
Hi,
the parent node of <subnode1-2>29.99</subnode1-2> is (node1), how can do to get <node1> throw <subnode1-2>29.99</subnode1-2> the sub node of <node1>.
As per my understanding the parent node of <subnode1-2>29.99</subnode1-2> is book not the node1.
If you want node 1 as a parent of subnode1-2 than your xml will look like this.
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
<fathernode>Harry Potter</fathernode>
<node1>
<subnode1>29.99</subnode1>
<subnode2>29.99</subnode2>
</node1>
<node2>
<subnode1>19.99</subnode1>
<subnode2>19.99</subnode2>
</node2>
</book>
</bookstore>
and also if you want tom retrive float data than refer following XPATH.
"//book[[price='1000']]/price/text()"
Regards,
Manoj Bilthare
User | Count |
---|---|
13 | |
6 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.