How to Use XML to Represent Structured Data

Start off the XML document by writing the XML declaration., Add a root element., Add children and sub-children tags., Give the necessary attributes., Close all your tags., Make sure the case is relevant., Comment to make it clear., Save the XML file...

8 Steps 1 min read Medium

Step-by-Step Guide

  1. Step 1: Start off the XML document by writing the XML declaration.

    The XML declaration does not show in the XML document, but the document cannot work without it. , The root element must cover all of the XML document except the declaration, otherwise there will be an error.<case...> </case>

    Children are tags contained inside the root element.

    Sub-children are inside the children.

    The tags on the same level are called siblings.

    The tags that are predecessors of any tags are their parent.

    The <root> element is the parent of all tags.

    Children tags include victim, possiblekiller, date.

    There are no sub-children in the example. , Attributes are given like in HTML.

    A <tag attribute="value"></tag> works here too.

    But as XML is designed to carry information, tags are preferred to attributes.<date> <dd>1</dd> <mm>2</mm> <yyyy>2011</yyyy> </date>

    HTML forgives small tag closing mistakes but XML is undeniably brutal in checking the document.

    To close a line break tag or an open tag, use a space and a slash(/).<open-tag></open-tag>

    <killer> and <killer> are not the same. , Comment formats are the same as in HTML.<!-- This is a comment
    -->
  2. Step 2: Add a root element.

  3. Step 3: Add children and sub-children tags.

  4. Step 4: Give the necessary attributes.

  5. Step 5: Close all your tags.

  6. Step 6: Make sure the case is relevant.

  7. Step 7: Comment to make it clear.

  8. Step 8: Save the XML file as "filename.xml".

Detailed Guide

The XML declaration does not show in the XML document, but the document cannot work without it. , The root element must cover all of the XML document except the declaration, otherwise there will be an error.<case...> </case>

Children are tags contained inside the root element.

Sub-children are inside the children.

The tags on the same level are called siblings.

The tags that are predecessors of any tags are their parent.

The <root> element is the parent of all tags.

Children tags include victim, possiblekiller, date.

There are no sub-children in the example. , Attributes are given like in HTML.

A <tag attribute="value"></tag> works here too.

But as XML is designed to carry information, tags are preferred to attributes.<date> <dd>1</dd> <mm>2</mm> <yyyy>2011</yyyy> </date>

HTML forgives small tag closing mistakes but XML is undeniably brutal in checking the document.

To close a line break tag or an open tag, use a space and a slash(/).<open-tag></open-tag>

<killer> and <killer> are not the same. , Comment formats are the same as in HTML.<!-- This is a comment
-->

About the Author

K

Kenneth Diaz

Committed to making crafts accessible and understandable for everyone.

69 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: