Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检查xml中是否存在行_Javascript_Xml - Fatal编程技术网

Javascript 检查xml中是否存在行

Javascript 检查xml中是否存在行,javascript,xml,Javascript,Xml,我希望能够检查我的xml,xmlChecklistItem是否已经包含某一行 我的代码: var node = xmlTemp.selectSingleNode("//ChecklistItem/Row"); 其中my node.xml等于ff: <Row piID="S000000051" piItemName="Communications - Cable TV"/> xmlChecklistItem如下所示: <ChecklistItem> <Row

我希望能够检查我的xml,xmlChecklistItem是否已经包含某一行

我的代码:

var node = xmlTemp.selectSingleNode("//ChecklistItem/Row");
其中my node.xml等于ff:

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

xmlChecklistItem如下所示:

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

对其使用xPath


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

可能值得指出的是,您正在使用属性选择器(括号和at符号)
节点[@your attribute='value']
。有关xPath的更多信息:
string xPath="//ChecklistItem/Row[@piID='S000000051'];
var node = xmlTemp.selectSingleNode(xPath);

if(node == null){
// the row does not exist
}