programming4us
programming4us
DATABASE

SQL Server 2008 : Explaining XML - Well-Formed XML

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
XML is a framework for storing information in a tree. The XML document must exactly have one root tag and must have a start-tag (< >) and end-tag (</>). An XML document must adhere to the XML syntax rules, or it is not a valid document. Figure 1 is a well-formed XML document.
Figure 1. A Well-Formed XML Document
<person>
<name>Steve Long</name>
</person>

In addition, text can be contained in the root tag. These are called attributes. For example, Figure 2 shows a sample XML document in which attributes are contained in the root tag.

Figure 2. Using Attributes in an XML Document
<car make="chevrolet">
<model>cavalier</model>
<year>2005</year>
</car>

XML requires that you properly nest elements in your XML document. Overlapping cannot occur, and as mentioned earlier, you need to end your XML with the end-tag (</>). Figure 3 is not a well-formed XML document. You will see that the <year> element overlaps the <car> element.

Figure 3. Not a Well-Formed XML Document
<car>hyundai<year>1997</year></car>

XML also has the flexibility to contain empty data. For example, in Figure 4, you will see that there is no price available for the car. An empty-element tag resembles a start-tag but contains a slash just before the closing angle bracket.

Figure 4. Empty Data Usage
<car make="chevrolet">
<model>cavalier</model>
<year>2005</year>
<price />
</car>

Notice that the price does not have an end-tag (</>). That’s because in XML there are different ways to specify the ending of a tag.

<price></price>
<price />
<price/>

XML documents must conform to syntax rules. Here are some of the rules to follow when you are creating a well-formed XML document.

  • All attribute values are quoted with either single (‘) or double (“) quotes. Single quotes close a single quote, and double quotes close a double quote.

  • Tags may be nested but must not overlap. Each nonroot element must be completely contained in another element.

  • Empty elements may be marked with an empty-element (self-closing) tag, such as <NoData/>. This is equal to <NoData></NoData>.

  • Element names are case-sensitive.

XML Examples

<person>
<name>Steve Long</name>
</person>

<car make="chevorlet">
<model>cavalier</model>
<year>2005</year>
<price/>
</car>

<root>
<customer id="17" firstname="Bob" lastname="Smith">
<address type="home" address1="763 Main Street" city="Anytown"
state="CA" zipcode="93762"/>
<order id="17">
<line_item part_no="12" qty="1" price="12.99"/>
<line_item part_no="73" qty="2" price="6.95"/>
<line_item part_no="17" qty="1" price="2.95"/>
</order>
</customer>
</root>
Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us