您想要标签名称吗?使用rootElement.getTagName();
从Java文档中:
公共字符串getLocalName()
Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as Document.createElement(), this is always null. Since: DOM Level 2.
公共字符串getTagName()
The name of the element. If Node.localName is different from null, this attribute is a qualified name. For example, in:
...
,
tagName has the value “elementExample”. Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.