Rakesh Mahapatro
Rakesh Mahapatro

Reputation: 866

get current node value through xpath

<E  st="SS"  >
        <id>789</id>
        <name>Study  Table 1200 C2</name>
        <vlid>1</vlid>
        <E  st="SS"  >
            <id>567</id>
            <name>Study  Table1</name>
            <vlid>94611431277729312</vlid>
        </E>
        <E  st="SS"  >
            <id>345</id>
            <name>Study -SOFT1</name>
            <vlid>94611431277729311</vlid>
        </E>
        <E  st="SS"  >
            <id>123</id>
            <name>Study  Table 02</name>
             <vlid>94611431277729309</vlid>
        </E>
    </E>

in this i am trying to get the node Value of id where vlid=3. the xpath i have written is (//E[vlid=94611431277729312]/id). the result is <id>567</id>,<id>345</id><id>123</id>

rather i want only one id i.e <id>567</id>. please help me out why i am unable to get the excepted output.

Thanks In Advance

Upvotes: 0

Views: 374

Answers (2)

Bob
Bob

Reputation: 1497

it will work if you will match the value as string

//E[vlid="94611431277729312"]/id

Upvotes: 1

Buffalo
Buffalo

Reputation: 4042

Try this:

//E[vlid=3]/id[2]

Like Colin said, try to accept answers that solve your problem.

Upvotes: 0

Related Questions