Search code examples
c#xmlxpathxpathnavigator

Why can't I get the specific node under some condition?


Why doesn't this xpath work with me? I want the current title if the language _id =2

./title[language_id=2]

<news pnumber="1" id="1"><event_id>578</event_id><event_type_id>1</event_type_id><language_id>2</language_id><title>meeting</title></news>



<news pnumber="1" id="1"><event_id>578</event_id><event_type_id>1</event_type_id><language_id>1</language_id><title>meeting</title></news>

Solution

  • The correct XPath expression is

    //title[../language_id=2]