XML – DOM


  1. DOM is a language and platform neutral definition i.e. interfaces are defined for different objects comprising the DOM but no specifics of implementation are provided.
  2. XML document can be represented as a tree that shows all elements and their relationships to one another.
  3. Each item in the tree is a node – an atomic piece of information that can be manipulated
  4. 2 unicode formats are the basis of XML characters – UTF-8 and UTF-16.
  5. DOM working:
    1. Parses the file, breaking the file into individual elements, attributes etc.
    2. Creates a representation of XML file as a node tree
    3. Access the contents of the document through the node tree
  6. DOM loads an entire document into memory and parses it into a document tree. It tends to consume an inordinate amount of memory.
  7. Node parentNode – a property in object Node : For Document, DocumentFragment and Attr nodes, parentNode is always null
  8. Node cloneNode(boolean deep) – a method in object Node : Duplicate node that is created has no parent
  9. Element createElement (DOMString tagName) – a method in Document : This does not actually attach the element to the node tree. For that appendChild() method is called.
  10. Node setNamedItem(Node nodeArg) – a method in NamedNodeMap : Same Attr node may not be added to more than one element, the Attr node needs to be first cloned before it may be added elsewhere.
  11. Node removeNamedItem(DOMString name) – a method in NamedNodeMap : Attr nodes with defaults removed in this way are instead modified to take the default values.