DOM: Document Object Model
你用的Document, Node, Element, NodeList就是org.w3c.dom包里的, 这也可以说是DOM了.
DOM其实就是用来描述一个XML文档的模型啦, 你已经用了DOM啦,你把一个XML格式的文本文件分析成了一个DOM树, 恭喜 {:D

解决方案 »

  1.   

    本人认为DOM是一个象协议规范一样的东西,单独DOM的存在没有什么作用,它需要有相应的技术支持才能发挥起作用!现在DOM已经被绝大多数的开发语言所接受,提供了相应的操作DOM的API。如java的JDOM,相应的API统称为JAXP~~
      

  2.   

    我还有一个问题,我的Element 的对象怎么没有getChild的方法,就像上面的程序里的DBServerIP=root.getChild("DBServerIP").getText();
    我用的事j2sdk1.4.2Element 好像继承的NODE类。我查了j2sdk1.4.2也没有看到有getChild的方法,不知道为什么?????
      

  3.   

    推荐一本《JavaXML程序元参考手册》
      

  4.   

    个人认为,dom就是一种对xml的理解方式。它以树的方式去理解xml文件,所以出现了那些Node,Element等概念
      

  5.   

    我的element对象里也没有getchild方法
    而且我试图从一个xml文档里读数据,并通过system.out.print输出,总是输出为空
    不知道这是怎么回事,哪位知道,指点一下?
      

  6.   

    DOM的Node 和 Element 类里确实没有,getChild() 和getText()的方法,Element的方法:
     String getAttribute(String name) 
              Retrieves an attribute value by name. 
     Attr getAttributeNode(String name) 
              Retrieves an attribute node by name. 
     Attr getAttributeNodeNS(String namespaceURI, String localName) 
              Retrieves an Attr node by local name and namespace URI. 
     String getAttributeNS(String namespaceURI, String localName) 
              Retrieves an attribute value by local name and namespace URI. 
     NodeList getElementsByTagName(String name) 
              Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree. 
     NodeList getElementsByTagNameNS(String namespaceURI, String localName) 
              Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree. 
     String getTagName() 
              The name of the element. 
     boolean hasAttribute(String name) 
              Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise. 
     boolean hasAttributeNS(String namespaceURI, String localName) 
              Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. 
     void removeAttribute(String name) 
              Removes an attribute by name. 
     Attr removeAttributeNode(Attr oldAttr) 
              Removes the specified attribute node. 
     void removeAttributeNS(String namespaceURI, String localName) 
              Removes an attribute by local name and namespace URI. 
     void setAttribute(String name, String value) 
              Adds a new attribute. 
     Attr setAttributeNode(Attr newAttr) 
              Adds a new attribute node. 
     Attr setAttributeNodeNS(Attr newAttr) 
              Adds a new attribute. 
     void setAttributeNS(String namespaceURI, String qualifiedName, String value) 
              Adds a new attribute. Node 类的方法 : Node appendChild(Node newChild) 
              Adds the node newChild to the end of the list of children of this node. 
     Node cloneNode(boolean deep) 
              Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. 
     NamedNodeMap getAttributes() 
              A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise. 
     NodeList getChildNodes() 
              A NodeList that contains all children of this node. 
     Node getFirstChild() 
              The first child of this node. 
     Node getLastChild() 
              The last child of this node. 
     String getLocalName() 
              Returns the local part of the qualified name of this node. 
     String getNamespaceURI() 
              The namespace URI of this node, or null if it is unspecified. 
     Node getNextSibling() 
              The node immediately following this node. 
     String getNodeName() 
              The name of this node, depending on its type; see the table above. 
     short getNodeType() 
              A code representing the type of the underlying object, as defined above. 
     String getNodeValue() 
              The value of this node, depending on its type; see the table above. 
     Document getOwnerDocument() 
              The Document object associated with this node. 
     Node getParentNode() 
              The parent of this node. 
     String getPrefix() 
              The namespace prefix of this node, or null if it is unspecified. 
     Node getPreviousSibling() 
              The node immediately preceding this node. 
     boolean hasAttributes() 
              Returns whether this node (if it is an element) has any attributes. 
     boolean hasChildNodes() 
              Returns whether this node has any children. 
     Node insertBefore(Node newChild, Node refChild) 
              Inserts the node newChild before the existing child node refChild. 
     boolean isSupported(String feature, String version) 
              Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. 
     void normalize() 
              Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. 
     Node removeChild(Node oldChild) 
              Removes the child node indicated by oldChild from the list of children, and returns it. 
     Node replaceChild(Node newChild, Node oldChild) 
              Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. 
     void setNodeValue(String nodeValue) 
              The value of this node, depending on its type; see the table above. 
     void setPrefix(String prefix) 
              The namespace prefix of this node, or null if it is unspecified. 
    Document 类的方法 : Attr createAttribute(String name) 
              Creates an Attr of the given name. 
     Attr createAttributeNS(String namespaceURI, String qualifiedName) 
              Creates an attribute of the given qualified name and namespace URI. 
     CDATASection createCDATASection(String data) 
              Creates a CDATASection node whose value is the specified string. 
     Comment createComment(String data) 
              Creates a Comment node given the specified string. 
     DocumentFragment createDocumentFragment() 
              Creates an empty DocumentFragment object. 
     Element createElement(String tagName) 
              Creates an element of the type specified. 
     Element createElementNS(String namespaceURI, String qualifiedName) 
              Creates an element of the given qualified name and namespace URI. 
     EntityReference createEntityReference(String name) 
              Creates an EntityReference object. 
     ProcessingInstruction createProcessingInstruction(String target, String data) 
              Creates a ProcessingInstruction node given the specified name and data strings. 
     Text createTextNode(String data) 
              Creates a Text node given the specified string. 
     DocumentType getDoctype() 
              The Document Type Declaration (see DocumentType) associated with this document. 
     Element getDocumentElement() 
              This is a convenience attribute that allows direct access to the child node that is the root element of the document. 
     Element getElementById(String elementId) 
              Returns the Element whose ID is given by elementId. 
     NodeList getElementsByTagName(String tagname) 
              Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree. 
     NodeList getElementsByTagNameNS(String namespaceURI, String localName) 
              Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree. 
     DOMImplementation getImplementation() 
              The DOMImplementation object that handles this document. 
     Node importNode(Node importedNode, boolean deep) 
              Imports a node from another document to this document. NodeList 的方法: int getLength() 
              The number of nodes in the list. 
     Node item(int index) 
              Returns the indexth item in the collection. 建议你看看jdk的帮助文档,上面写的很清楚!!