xmlxpathgenericsxquery

XQuery to get a list of all attributes an element has


Is there a generic way of determining all attributes (and their values) from an XML node using XQuery/XPath?

<parent>
   <something attr1="123" attrA="abc" ..... attrAnythingelse="blablabla"/>
</parent>

Solution

  • Get all attributes for the current node using XPath:

    @*
    

    Is that what you're after?

    The names and values of the attributes can be extracted per attribute:

    name(@*[1])
    string(@*[1])
    

    Depends on what you want to do with them.