Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022


Rules For a Well-formed XML Document

You can be loose and sloppy with HTML, making all kinds of coding errors, and browsers will still display the web page, probably with no visible damage. But sloppy XML code is not permitted. An error in an XML document will bring your application to a halt. Here are the basic rules for creating well-formed XML.

An XML document has exactly one root element. The root element encloses all the other elements and is the top-level parent element to all the other elements. In the code shown below, <catalog> is the root element.

<catalog>
   <book newused="new">
      <author>O'Brien, Tim</author>
      <title>Microsoft .NET: The Programming Bible</title>
      <price>36.95</price>
      <publish_date>2000-12-09</publish_date>
      <description>Microsoft's .NET initiative is explored in detail.</description>
   </book>
   <book newused="used">
      <author>O'Brien, Tim</author>
      <title>MSXML3: A Comprehensive Guide</title>
      <price>36.95</price>
      <publish_date>2000-12-01</publish_date>
      <description>The Microsoft MSXML3 parser is covered in detail.</description>
   </book>
   <book newused="new">
      <author>Galos, Mike</author>
      <title>Visual Studio 7: A Comprehensive Guide</title>
      <price>49.95</price>
      <publish_date>2001-04-16</publish_date>
      <description>Microsoft Visual Studio 7 is explored in depth.</description>
   </book>
</catalog>

XML tags are case sensitive. Closing tags must have the same upper-case, lower-case arrangement as their respective opening tag.

<author>O'Brien, Tim</author>
<TITLE>Microsoft .NET: The Programming Bible</TITLE>
<price>36.95</price>

All XML elements must have a closing tag.

<book newused="new">
   <author>O'Brien, Tim</author>
   <title>Microsoft .NET: The Programming Bible</title>
   <price>36.95</price>
   <publish_date>2000-12-09</publish_date>
   <description>Microsoft's .NET initiative is explored in detail.</description>
</book>

All opening and closing tags must match.

<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<price>36.95</price>

All tags must be nested correctly. When an element appears within another element, it is said to be nested within that element. An element which is nested inside another element must have its closing tag before the closing tag of the outer element.

<catalog>
   <book newused="new">
      <author>O'Brien, Tim</author>
      <title>Microsoft .NET: The Programming Bible</title>
   </book>
</catalog>

All attribute values must be enclosed in single or double quotation characters.

<catalog>
   <book newused="new">
      <author>O'Brien, Tim</author>
      <title>Microsoft .NET: The Programming Bible</title>
      <price>36.95</price>
      <publish_date>2000-12-09</publish_date>
      <description>Microsoft's .NET initiative is explored in detail.</description>
   </book>
   <book newused="used">
      <author>O'Brien, Tim</author>
      <title>MSXML3: A Comprehensive Guide</title>
      <price>36.95</price>
      <publish_date>2000-12-01</publish_date>
      <description>The Microsoft MSXML3 parser is covered in detail.</description>
   </book>
</catalog>

An error in an XML document will bring your application to a halt. If you follow these rule for creating well-formed XML code, there is much less chance of creating an error, and any error will be easier to locate.

RSS Feed RSS Feed


Follow Stephen Bucaro Follow @Stephen Bucaro


Fire HD
[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyrightę2001-2010 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269