PHP: Check if XML node exists with attribute

前端 未结 4 513
轻奢々
轻奢々 2020-12-06 07:19

I can\'t seem to figure this one out. I have the following XML file:



  
           


        
4条回答
  •  难免孤独
    2020-12-06 07:55

    This XPath expression:

           /*/*/building[@name = 'Shiny Red']

    selects the element named building the value of whose name attribute is 'Shiny Red' and that is a child of a child of the top element.

    Probably in PHP there is a way to evaluate XPath expressions, then just evaluate the above XPath expression and use the result.

提交回复
热议问题