What are the difference between an element and a node in XML ?

What are the difference between an element and a node in XML ?

Asked on December 17, 2018 in XML.
Add Comment


  • 3 Answer(s)

    Here is the statement:

      • The primary data type for the entire DOM is the Node object.

     

      • Node should be an element node, a text node, an attribute node or any of the “Node types”.

     

      • An XML element is all from including the element’s start tag to the element’s end tag.

     

    Answered on December 17, 2018.
    Add Comment

    DOM spec defines some types of nodes were:

    1. Document — Element (maximum of one), ProcessingInstruction, Comment, DocumentType
    2. DocumentFragment — Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
    3. DocumentType — no children
    4. EntityReference — Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
    5. Element — Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
    6. Attr — Text, EntityReference
    7. ProcessingInstruction — no children
    8. Comment — no children
    9. Text — no children
    10. CDATASection — no children
    11. Entity — Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
    12. Notation — no children

     

    XML Infoset that used by XPath has a smaller set of nodes:

    1. The Document Information Item
    2. Element Information Items
    3. Attribute Information Items
    4. Processing Instruction Information Items
    5. Unexpanded Entity Reference Information Items
    6. Character Information Items
    7. Comment Information Items
    8. The Document Type Declaration Information Item
    9. Unparsed Entity Information Items
    10. Notation Information Items
    11. Namespace Information Items

    XPath have some types of nodes:

    1. root nodes
    2. element nodes
    3. text nodes
    4. attribute nodes
    5. namespace nodes
    6. processing instruction nodes
    7. comment nodes

        An element is a type of node. Many other types of nodes abide and serve different purposes.

    Answered on December 17, 2018.
    Add Comment

    Simple answer:

         An element is an individual kind of node. A node can be a number of various type of things: some text, an element, an entity and a comment. 

    Answered on December 17, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.