Topic
  • 1 reply
  • Latest Post - ‏2013-05-11T08:38:22Z by herbert_gruendken
SystemAdmin
SystemAdmin
746 Posts

Pinned topic XPath Search

‏2012-10-26T18:44:14Z |
Hello,
I am doing a little xml learning.
Here is what I want to do....

I want to select a node where a child node has a specific value. Once I have that node, I then want to get other specific child node values to use/display in my html.
So, I am searching the xml file for a specific value in a node. Once found, I want to select the parent of that node and then get at the child node values.

Example:
<?xml version="1.0"?>
<locations>
<loc>
<id>121</id>
<user>Joe Smith</user>
<section>AAA</section>
</loc>
<loc>
<id>122</id>
<user>Bill Jones</user>
<section>BBB</section>
</loc>
</locations>

So I want to search the xml file above and select the "loc" node whose "id" node value = 122. I then want to get the remaining child nodes (user and section) from that selected "loc" node.

I am using javascript to do this.

It seems it should be easy enough to do....I just have not gotten anything to work yet.
Any assistance would be greatly appreciated.

Regards,
Mike
  • herbert_gruendken
    herbert_gruendken
    2 Posts

    Re: XPath Search

    ‏2013-05-11T08:38:22Z  

    Hallo,

    this xpath returns you all childnodes of loc :  //loc[id=122]/*

    herbert