Reputation: 109
Here is the xml from which i want to retrieve the value.
<dsml>
<entries>
<entry dn="uid=7686,c=in,ou=pages,o=example.com">
<att name="uid">
<value>7568766</value>
<value>756876634</value>
</att><att name="callname">
<value>jhsadkjh</value>
<value>jhsadkjhakjdgakj</value>
</att></entry>
</entries>
</dsml>
As you can see that each attribute is having 2 values associated with it. I want to fetch only first one. Below are some xpaths i have used:
//dsml/entries/entry/att[@name = 'uid']/value[1]
//dsml/entries/entry/att[@name = 'uid']/value/[1]
But its always throwing exception.
Upvotes: 0
Views: 183
Reputation: 159
This xpath fetch only second 'value' tag from each tag named 'att':
//dsml/entries/entry/att/value[1]
or, if you want to fetch 'value' only from "uid", you can use:
//dsml/entries/entry/att[@name='uid']/value[1]
Upvotes: 2
Reputation: 64
You are using different names for the same element. entries
as open tag and enteries
as closing tag. These names should be identical. Also in xml the name of element is att
and in Xpath you are trying to find attr
Upvotes: 0