0

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.

2
  • And you have tried... what, so far? Please tell me that you don't just came by to have somebody write code for you. Commented Oct 30, 2013 at 6:43
  • Your XML file is not namespace-well-formed. It has no declaration for the namespace prefix "abc". Commented Oct 30, 2013 at 8:55

2 Answers 2

3

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

//abc:person[@id = 1] 
Sign up to request clarification or add additional context in comments.

Comments

1

In XPath 2 you could also use:

//*:person[@id = 1] 

if you cannot declare a namespace

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.