XML Basics


9.0D

 

Extensible Markup Language (XML) is a standard for encoding data. XML allows you to apply markup, in the form of tags, to data. A basic XML starting tag is a string of text enclosed using the < and > characters. This string of text is known as the tag name. Tag names are case-sensitive and must start with letters, or an underscore. The rest of the tag name can contain letters, digits, hyphens, underscores, and periods.

 

<PHONE>

 

A basic XML ending tag is a string of text with a leading / character that is enclosed using the < and > characters.

 

</PHONE>

 

A matching pair of XML starting and ending tags constitutes an XML element. The name of the element is the tag name of the enclosing tags.

 

<PHONE>(111) 123-1235</PHONE>

 

XML elements identify named sections of data, and may contain other XML elements, XML attributes, or text.

 

<PERSON>

<---------------------

 

  <NAME>Bill</NAME>

<- element with text

| element with

  <PHONE>(111) 123-1235</PHONE>

<- element with text

| contained elements

</PERSON>

<---------------------

 

 

Relationships between XML elements are described in the terms of child and parent elements. Every XML document must start with a single document or root XML element that is the parent of all other XML elements.

 

XML attributes allow the addition of information about an XML element using name=value pairs. XML attributes are placed in the starting tag of the element, following the tag name. XML attributes are separated from the tag and each other by using a leading space character. The value of an XML attribute is enclosed in either single or double quotes.

 

 

<PERSON PERSONID="5622">

<- PERSONID is an attribute

  <NAME>John Smith</NAME>

<- contained element

</PERSON>

 

 

XML elements can contain both XML attributes and text at the same time.

 

<PERSON PERSONID="5622">John Smith</PERSON>

 

 

See Also: XML Support



PL/B Language Reference XML Support XML Document Structure