假设您有这样的XML结构:
<?xml version="1.0" encoding="UTF-8" ?>
<ISExport Version="2.4" productVersion="2.4">
<ControlFlow name="CF_Order" typeId="2" >
<Variables>
<Element paramType="LOCAL" name="$V_FromTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_ToTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_TableName" datatype="VARCHAR" size="128" >
</Element>
</Variables>
</ControlFlow>
<ControlFlow name="CF_Action" typeId="2" >
<Variables>
<Element paramType="LOCAL" name="$V_FromTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_ToTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_TableName" datatype="VARCHAR" size="128" >
</Element>
</Variables>
</ControlFlow>
<ControlFlow name="CF_Task" typeId="2" >
<Variables>
<Element paramType="LOCAL" name="$V_FromTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_ToTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_TableName" datatype="VARCHAR" size="255" >
</Element>
</Variables>
</ControlFlow>
<ControlFlow name="CF_Sales" typeId="2" >
<Variables>
<Element paramType="LOCAL" name="$V_FromTS" datatype="TIMESTAMP" >
</Element>
<Element paramType="LOCAL" name="$V_ToTS" datatype="TIMESTAMP" >
</Element>
</Variables>
</ControlFlow>
</ISExport>
我如何编写XPATH查询到
name = $V_TableName
和元素size <> '128'
name = $V_TableName
我正在使用Notepad ++的XPATH插件。 任何帮助表示赞赏。感谢
答案 0 :(得分:-1)
更新#1,以确保我们正在测试相同元素的属性 -
//ControlFlow[Variables/Element[@name='$V_TableName' and not(@size = '128')]]/@name
试试这些
1)列出所有ControlFlow名称,其中元素名称= $ V_TableName和元素大小&lt;&gt; &#39; 128&#39;
//ControlFlow[Variables/Element/@name='$V_TableName' and Variables/Element/@size != '128']/@name
2)列出所有没有Element name = $ V_TableName
的ControlFlow名称//ControlFlow[not(Variables/Element/@name='$V_TableName')]/@name