How to get tag name of root element in an XML document w/ XSLT?

前端 未结 4 1027
遇见更好的自我
遇见更好的自我 2020-12-16 10:27

I\'m interested in assigning the tag name of the root element in an xml document to an xslt variable. For instance, if the document looked like (minus the DTD):

<         


        
4条回答
  •  情话喂你
    2020-12-16 11:04

    Use the XPath name() function.

    One XPath expression to obtain the name of the top (not root!) element is:

           name(/*)

    The name() function returns the fully-qualified name of the node, so for an element the string "bar:foo" will be returned.

    In case only the local part of the name is wanted (no prefix and ":"), then the XPath local-name() function should be used.

提交回复
热议问题