Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
Xml 如何选择具有特定属性的所有元素?用TinyXPath_Xml_Xpath_Tinyxpath - Fatal编程技术网

Xml 如何选择具有特定属性的所有元素?用TinyXPath

Xml 如何选择具有特定属性的所有元素?用TinyXPath,xml,xpath,tinyxpath,Xml,Xpath,Tinyxpath,选择具有属性A的所有元素的XPath表达式是什么 const char* xpath = "//\*/\*[@A]" 此XPath选择具有A属性的所有元素: //*[@A] 不确定是否需要转义*,但您当前的XPath正在选择具有@A且是元素子元素的所有元素,因此它将与大多数元素匹配,但如果文档元素具有A属性,您将错过该元素(因为它没有父元素)。

选择具有属性A的所有元素的XPath表达式是什么

const char* xpath = "//\*/\*[@A]"

此XPath选择具有A属性的所有元素:

//*[@A]

不确定是否需要转义
*
,但您当前的XPath正在选择具有
@A
且是元素子元素的所有元素,因此它将与大多数元素匹配,但如果文档元素具有A属性,您将错过该元素(因为它没有父元素)。