cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the parent node of the current node?

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

agentry_src
Active Contributor
0 Kudos

Could you provide some more details on what you are referring to?

Thanks,

Mike

Former Member
0 Kudos

i want to get the parent node of the current node and not the parent of the parent node of the current node, i have a node and all i want is to get her first parent ( first parent from down to up ) ,

thannx for your replay

Former Member
0 Kudos

[http://www.w3schools.com/xpath/xpath_syntax.asp|http://www.w3schools.com/xpath/xpath_syntax.asp]

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

thanx for your answer, i am parsing the xml document, and wihle i am get it into my table , as i said i wanted to get the parent node of some special node,

thanx

Former Member
0 Kudos

Hi

can you disscuss some more details or your xml document.

and also exactly which parent node you need.

Regards,

Manoj Bilthare

Former Member
0 Kudos

<?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>.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi, sorry i 've done a mistake,

exactely as you have said, my xml looks like that, but how can i get the parent node of the subnode1-2

there is a metoth get_parent but it didnt work with me, would you please help me for this,

i am parsing the xml using DOM and abap

thank you very much

Former Member
0 Kudos

You might want to go to the abap forums. I have done a lot of abap but never had to parse any xml with it.

Something like this will get the name of the parent node in MII.

name(//subnode1/..)

Former Member
0 Kudos

yes, i understand what you mean, but i cant change the xml, i am not allowd to do that, and there is no way to change it, i have to do this while parsing.