Elements and Structure of XML file

XML file consist of declaration, elements, attributes , tree and comments. Before going in details about these we will learn some basic points about their uses.

XML tags are case sensitive ( Uppercase and lowercase text are treated differently)
XML elements are to be properly nested.
XML documents have one root element.
XML file has on starting and ending tag
attributes value to be enclosed within double quotes

Let us start with one sample xml file, shown here.

XML Declaration

This is the first line in our XML file. Which reads like this.

<?xml version='1.0' standalone='yes'?>

In addition to Version we can declare about encoding and standalone. Standalone should say yes or no. Yes mean the file has internal DTD ( Document Type Definition) and No mean it is linked to an external DTD.

XML Elements

Elements are the main building block of an XML file. They used to store data, give idea about the data and many more. Here are some basic syntax to be followed. elements to start with letter or underscore. Numbers or other chars are not allowed at starting. No space is allowed in element name

<door_no>234-ac</door_no>

Nested Elements

We can keep elements within elements and they are known as nested elements.

<address>
<door_no>234-ac</door_no>
<street>Great Wall</street>
<city>Alabama</city>
</address>

Parent & Child element

Based on different node we can have child element and parent element. Each element can have only one parent element but parent can have multiple child element.

Sibilings

Child Elements having common parent element are known as Siblings

XML attributes.

We can use attributes to store data but the same can be done by using child elements also. However the best practice is to use attributes to give more information about the data and use child element to store data.

What is XML?


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer