dom api interface and methods


DOM API interface and methods

DOM API has given some fixed set of  interface and methods to  parse XML file and update XML file.

DOM interfaces

  1. Document    :     Document represents the entire XML document.
  2. Element        :     Element of DOM represents element of XML file it may contain value or attribute.
  3. Node             :      Node represents a single node in the document tree.The entire document is a document node this Node may be Element Node , Text Node or Attribute Node.
  4. NodeList      :      The NodeList interface is collection of nodes.
  5. Text               :      Text represents textual data of XML in DOM.
  6. Attr               :        Attr represents attribute of XML in DOM.

Common DOM methods

  1. Document.getDocumentElement()
  2. Node.getNodeName()
  3. Document.getElementsByTagName()
  4. List.item()
  5. Node.getFirstChild()
  6. Node.getLastChild()
  7. Node.getNextSibling()
  8. Node.getPreviousSibling()
  9. Node.getAttribute(attrName)

We can read XML file data using DOM in so many ways.

  1. First Approach
  2. Second Approach
  3. Third Approach

DOM parser






Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: info@w3sparks.com Sales: +91 8085506229