C xml Parser

Source: Internet
Author: User
Tags xml parser

XML Learning

  • XML is a markup language that does not have any behavior. It only describes the data in a structured manner.
  • The purpose of XML design is to transmit data (XML is the data independent, and data transmission between different platforms is not a problem, because they are all XML standards), not as HTML is to present data
  • XML labels need to be defined by themselves. They do not have predefined labels (Unlike HTML, there are many defined labels such as body h table)
  • XML can even be used as a small database

// --------------- Don't get pregnant after inserting it --------------

  • All XML Element labels must be disabled
  • XML tags are case sensitive.
  • XML labels must be correctly nested
  • The XML tag must have a root node.
  • The XML property value must be enclosed in quotation marks.
  • XML comment <! -- Xxxxxx -->

// --------------------- Insert -------------------------

The following is a reference from w3cshcool

XML attributes

Attributes usually provide information that is not part of the data. In the following example, the file type has nothing to do with data, but it is very important for the software that needs to process this element:

<file type="gif">computer.gif</file>
XML Element vs. Attributes

See these examples:

<person sex="female">  <firstname>Anna</firstname>  <lastname>Smith</lastname></person> <person>  <sex>female</sex>  <firstname>Anna</firstname>  <lastname>Smith</lastname></person> 

In the first example, sex is an attribute. In the second example, sex is a child element. Both examples provide the same information.

There are no rules to tell us when to use attributes and when to use subelements. In my experience, attributes are easy to use in HTML, but in XML, you should try to avoid using attributes. If the information is similar to data, use the child element.

XML attributes for metadata

Sometimes an ID reference is assigned to an element. These ID indexes can be used to identify XML elements in the same way as the ID attribute in HTML. This example demonstrates this situation:

<messages>  <note id="501">    <to>George</to>    <from>John</from>    id="502">    <to>John</to>    <from>George</from>    
 

The above ID is just an identifier used to identify different tabs. It is not part of the signature data.

Here we try to pass you the idea that metadata (data related to data) should be stored as attributes, and data itself should be stored as elements.

// --------------------- Insert -------------------------

The XML verified by DTD is a "legal" XML.

Plain C

XML Parser library available for use

1. Mini XML Chinese guide document: http://www.minixml.org/strfiles/93/minixml-cn.html

2. libxml2

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.