XML learning notes

Source: Internet
Author: User
Tags xml parser
The XML declaration is placed in the first line of the XML file, including the XML version and the encoding used. The XML declaration guides the XML parser to parse the XML file. For example:
<?xml version="1.0" encoding="ISO-8859-1"?>

The preceding example defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/Western European character set ).

XML version number: Specifies the XML version number used by the parser to parse the file.

XML Encoding: The file encoding format used by the parser to parse the file.
XML encoding definition conventions:
Assume that the XML file only has standard ASCII encoding, you do not need to display the definition encoding format in the XML declaration.
If the XML file is unicode encoded and the file contains a BOM (byte order mark), you can use BOM to determine the encoding method used by the sequence, and you do not need to display the definition encoding format in the XML declaration.
Assume that the XML file is unicode encoded but does not have Bom, the defined encoding format must be displayed in the XML declaration.

If the XML file is in another encoding format, the defined encoding format must be displayed in the XML declaration.


XML namespace the XML namespace alias is defined in XML elements using the xmlns attribute. For example:
<f:table xmlns:f="http://www.w3school.com.cn/furniture">   <f:name>African Coffee Table</f:name>   <f:width>80</f:width>   <f:length>120</f:length></f:table>

The role of a namespace: It can be understood as a Java package. The namespace and element name together constitute the globally unique qualified name of the XML Element (qualified name ), the parser can avoid conflicting element names in different XML files.

Namespace DefinitionThe namespace definition consists of two parts: prefix and space name. In the preceding example, F is the prefix, and http://www.w3school.com.cn/furnitureis the space name.

The role of a space name is to assign a unique namespace name to the namespace. a url is usually used by the caller. This URL does not necessarily point to an existing webpage, but many companies often point it to a webpage that includes namespace information.
Because the space name is usually longer than the delimiter, the delimiter uses a simplified prefix before the element name to avoid the XML document being too lengthy and difficult to read.
Namespace Scope: The function scope is the full content of the element where the namespace definition is located, corresponding to the above sample, namespace xmlns: F = "http://www.w3school.com.cn/furniture" is effective between <Table> and </table>.
Default namespace: If the prefix is not defined during definition, all elements in the namespace definition range use the namespace as the default namespace. For example:
<table xmlns="http://www.w3school.com.cn/furniture">   <name>African Coffee Table</name>   <width>80</width>   <length>120</length></table>

In this example, the namespace of the table, name, width, and length elements is http://www.w3school.com.cn/furniture.


XML-related knowledge index



Exam Materials

Http://www.oracle.com/technetwork/cn/articles/srivastava-namespaces-098626-zhs.html

Http://www.w3school.com.cn/

XML learning notes

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.