0

I wanna be able to check if my xml, xmlChecklistItem already contains a certain row.

my code:

var node = xmlTemp.selectSingleNode("//ChecklistItem/Row");

where my node.xml is equal to the ff:

<Row piID="S000000051" piItemName="Communications - Cable TV"/>

and xmlChecklistItem goes like this:

<ChecklistItem>
<Row piID="S000000051" piItemName="Communications - Cable TV"/>
</ChecklistItem>

2 Answers 2

1
string xPath="//ChecklistItem/Row[@piID='S000000051'];
var node = xmlTemp.selectSingleNode(xPath);

if(node == null){
// the row does not exist
}
Sign up to request clarification or add additional context in comments.

Comments

0

use xPath for it

var node = xmlTemp.selectSingleNode("//ChecklistItem/Row[@piID='S000000051']");

1 Comment

Might worth pointing out that you are making use of an attribute selector (the brackets and the at sign) Node[@your-attribute='value']. More on xPath: developer.mozilla.org/en-US/docs/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.