ttt
ttt

Reputation: 4004

xpath expression with namespace

If I have a XML file like this:

<abc:persons>
<abc:person id="1">
    ...
</abc:person>
<abc:person id="2">
    ...
</abc:person>
</abc:persons>

Given this, what's the xpath expression will be if I want to select person with id is 1.

Thanks.

Upvotes: 0

Views: 73

Answers (2)

BeniBela
BeniBela

Reputation: 16927

In XPath 2 you could also use:

//*:person[@id = 1]

if you cannot declare a namespace

Upvotes: 1

resigned
resigned

Reputation: 1084

Try searching for the element and using a predicate to distinguish the attribute values:

//abc:person[@id = 1]

Upvotes: 3

Related Questions