简体   繁体   English

获取具有特定属性的元素而不知道元素标记名称

[英]get element with specific attribute without knowing element tag name

I want to know how to get an element that has a specific attribute without knowing the tag name of the element. 我想知道如何获取具有特定属性的元素,而不知道元素的标记名称。 I know that in XPath you can write something like this: 我知道在XPath你可以写这样的东西:

//elementTag[@att="attValue"]

which searches for an element with the specified attribute. 它搜索具有指定属性的元素。 But is it possible to search for an element by only specifying the attribute tag name and the attribute value using XPath ? 但是,是否可以通过仅使用XPath指定属性标记名称和属性值来搜索元素?

I am using PHP. 我正在使用PHP。

All you have to do is to use a wildcard : 您所要做的就是使用通配符

//*[@att="attValue"]

See section Node Tests in the XSLT 1.0 spec. 请参阅XSLT 1.0规范中的节点测试部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM