我有一个简单的 xml 文档,我正在尝试使用 org.w3c.dom.Document 获取根节点的描述
<?xml version="1.0" encoding="ISO-8859-1"?><students mlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="students.xsd"><description>A bunch students and courses</description><student studentID="0144085" gender ="M"><firstname>Jack</firstname>
这是我的代码
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
builderFactory.setNamespaceAware(true);
builderFactory.setValidating(true);
builderFactory.setAttribute(JAXP_SCHEMA_LANGUAGE,
W3C_XML_SCHEMA);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
// parse the input stream
document = builder.parse(in);
document.getDocumentElement().normalize();
// JAXP
Node rootXMLNode = document.getDocumentElement();
DOMParser parser = new DOMParser();
//jf : set StudentINfoSet class properties
this.description = rootXMLNode.getTextContent();
//DOMUtilities.getAttributeString(rootXMLNode,"description");
现在 rootXMLNode.getTextContent(); 将整个 xml 文档作为字符串返回,那么我怎样才能获取根节点的描述标签。
太感谢了。