Select xml node by attribute name ignoring namespace of that attribute

前端 未结 2 1174
广开言路
广开言路 2020-12-18 02:56

I have a node like this:


I want to be able to select this element i

2条回答
  •  醉酒成梦
    2020-12-18 03:44

    Use:

    //meta[@*[local-name() = 'description']]
    

    This selects all meta elements in the XML document that have an attribute with local-name "description".

    By definition, the standard XPath function local-name() produces the name of the node from which the namespace prefix (if any) is stripped off.

    Do note: Always avoid using the // pseudo operator if the structure of the XML document is statically known. Often using // causes slow execution.

提交回复
热议问题