asp.net operations on XML files

Source: Internet
Author: User
Tags cdata comments processing instruction valid

It's been used recently. NET to do a Java software interface, where the development process involves a lot of the operation of XML documents, with the help of Microsoft MSDN and its own use of experience, is a brief introduction to the asp.net of XML document operations. One, XML document

As we all know, XML is the abbreviation for "Extensible Markup Language", which expands the markup language. It is a cross-platform, content-dependent technology in the Internet environment and a choice tool for handling distributed structure information in this era. Working groups under the auspices of the Consortium develop and support XML technologies that simplify the transfer of document information across the Internet.

XML documents fall into two categories: Valid XML documents and XML documents in a simplified format.

A simplified format XML document must adhere to the following principles:

l have at least one element

L Compliance with XML specifications

The L root element (for example, in the example above) should not be contained by other elements

L proper element nesting is necessary

L attribute values should be within the question mark

L All entities are declared except for the retention of entities

Valid XML

A valid XML document refers to an XML document that has a DTD reference file. A valid XML document must be at least the first XML document that is in a simplified format. The validity of the DTD file that follows this document facilitates the operation of the XML execution program and the display of the document in a compatible XML browser.

Examples of XML documents

Example 1-an XML document in a simplified format:

  <?xml version="1.0" standalone="no"?>
  <Mail>
  <From>Author</From>
  <To>Receiver</To>
  <Date> Thu, 7 Oct 1999 11:15:16 -0600</Date>
  <Subject>XML Introduction</Subject>
  <body><p>Thanks for reading<Br/>
  this article</p>
  <br/>
  <p>Hope you enjoyed this article</p>
  </body>
  </Mail>

Line 1th is an XML declaration in which the Version property indicates the edition of the XML, and the standalone property equals "No" to indicate that the markup declaration is not independent of the document's interior. An XML declaration can be considered a "run instruction". Although this declaration is not required, it is best to include it, which will improve the flexibility of the document.

Example 2-A valid XML document that adheres to the Mail.dtd file. The date element is omitted because it is optional in mail.dtd. Element P has a justify property. Between the body and P elements is comments text:

  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE Mail system "http://infowest.com/DTDS/mail.dtd">
  <Mail>
  <From>Author</From>
  <To>Receiver</To>
  <Cc>Receiver2</Cc>
  <Subject>XML Introduction</Subject>
  <body>Comments:<p align="justify">Thanks for reading<Br/>
  this article</p>
  <br/>
  <p>Hope you enjoyed this article</p>
  </body>
  </Mail>

Example 3-A valid XML document that adheres to the Mail.dtd file, exists with the date element and the CC element, and the P element owns the property right:

  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE Mail system "http://infowest.com/DTDS/mail.dtd">
  <Mail>
  <From>Author</From>
  <To>Receiver</To>
  <Cc>Receiver2</Cc>
  <Date> Thu, 7 Oct 1999 11:15:16 -0600</Date>
  <Subject>XML Introduction</Subject>
  <body>Comments:<p align = "right" >Thanks for reading<Br/>
  this article</p>
  <br/>
  <p>Hope you enjoyed this article</p>
  </body>
  </Mail>

XML documents can contain annotation information, and the syntax of annotations is similar to HTML. In addition to the "--" string, any textual information can be placed between the labeled <--and-->. The processing instruction Pi (processing instruction) can be embedded in the document, and the PI data component can be identified by the processing process.

The creator may want to include some code that is not parsed by the parser. The code can be placed in the ignored code snippet. The code snippets that can be ignored have the following syntax:

<[cdata[text messages that are ignored]]>

In short, ignoring the code snippet starts with the <[cdata[and end with]]>.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.