Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the root node in XML document?

user-image
Question added by Walaa Alhalabi , Sr. PMIS (Oracle BI Publisher) , Khatib & Alami
Date Posted: 2015/12/23
Ali Alawieh
by Ali Alawieh , Software Engineer (Android) , CME Offshore S.A.L

The root node is the "parent" node that all nodes are children of.

For example if you have an XML file where you are storing books, your root node would be <books> and your XML file would look something like this:

<books>

    <book id="1">

        <author id=""/>

        <page_numbers></page_numbers>

        <category id="5"/>

    </book>

    <book id="2">

        <author id=""/>

        <page_numbers></page_numbers>

        <category id="6"/>

    </book>

    <book id="3">

        <author id=""/>

        <page_numbers></page_numbers>

        <category id="2"/>

    </book>

</books>

 

The root node is especially useful when you try to access the file from software you are trying to make. Because parsers (objects made to read the file) like the DOM parser, load such file as a tree . And there has to be a parent node in the tree , that would be the root node.

 

XML loaded into memory as a tree

 

More Questions Like This