iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning XML Course: XML Syntax (2) - www.itechcollege.com XML Course: XML Syntax (2) - www.itechcollege.com
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
C++
ASP.NET
SQL
AJAX
FTP
XML

courses > XML > XML Syntax (2)

XML Syntax (2)

XML documents must contain one element that is the parent of all other elements. This element is called the root element.

<root>
<child>
<subchild>.....</subchild>
</child>
</root>

XML Attribute Values Must be Quoted

XML elements can have attributes in name/value pairs just like in HTML. But in XML the attribute value must always be quoted. Study the two XML documents below. The first one is incorrect, the second is correct:

<customer dateentry=08/11/2008>
<firstname>Michael</firstname>
<lastname>Smith</lastname>
</customer>

<customer dateentry="08/11/2008">
<firstname>Michael</firstname>
<lastname>Smith</lastname>
</customer>

The error in the first document is that the date attribute in the note element is not quoted.

Some characters have a special meaning in XML.

If you place a character like "<" inside an XML element, for example:

<category>GPS Products < $1000</category>

The character "<" will generate an error because the parser interprets it as the start of a new element. To avoid this error, replace the "<" character with an entity reference:

<category>GPS Products &lt; $1000</category>

There are 5 predefined entity references in XML:
&lt; < less than
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark

Note: Only the characters "<" and "&" are strictly illegal in XML. The greater than character is legal, but it is a good habit to replace it.

Comments in XML. The syntax for writing comments in XML is the same as in HTML.

<!-- This is a comment -->

In XML, White Space is Preserved. In an HTML file, multiple white space characters are reduced to a single white space. But in an XML file, the white space is not truncated.



  Back to Index Page
 Next Page:  

XML Introduction
XML Format and Structure
XML Elements
XML Attributes
XML Syntax 1
XML Syntax 2
XML Naming Rules and Practices
XML Using CDATA for Dealing with HTML Tags
Displaying XML into HTML
XML Parser
XML DOM
XMLHttpRequest Object 1
XMLHttpRequest Object 2
XMLHttpRequest Object 3
Create an XML File From a Database 1
Create an XML File From a Database 2
Save XML File on Server


Online Education, Online Training for Your Job, Distance Education, E-learning Programs for Your Career!Online Colleges, Online Universities, E-learning & Distance Education for Your Career! Easy Job Training & Online Courses.


   Email A Friend  
 
Earn Online Degree
for Your Job
I found a job after I earned an online degree!
Online classes for finding a Job. Online College, Online University, Degrees, E-learning school, online certificate Earn your
online degree now!
Online Training
for Good Job
Why I work so hard but earn so little? Why I cannot find a high paying job?
Online training for a Good Jobs. Online Degree, E-learning school, online certificate Go to
online school now!

Copyright ©2024, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech