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:
//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
?
I am using PHP.
All you have to do is to use a wildcard :
//*[@att="attValue"]
See section Node Tests in the XSLT 1.0 spec.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.