Basics of Ajax Learning: A brief introduction to Data island usage

Source: Internet
Author: User
Tags tagname

Data island refers to the existence of XML snippets in HTML Web pages, which form a collection of data in HTML, allowing us to integrate XML into HTML Web pages and script XML.

The data island has its own form, starting with the markup XML and having an id attribute in the start tag that specifies the name of the specified data island. (End with/xml, of course). The element XML contains content that is XML code. The data island is also divided into 2 species:

1 Embedded Data Island form

2 data Island form outside the nest

Say so much nonsense, or understand the following how to access the data island nodes and operations, after all, the use of XML in HTML is what we need to pay attention to. Let's get down to business:

Because of the property structure of the data island, accessing a data island is similar to accessing a Document object, which refers to an object that has properties and methods that we use to access and process XML documents, and create an XML Document object when an XML data island is read and parsed.

1) Data Island objects

Data island objects can be established using the value of ID in the < XML id= "XMLName" src= "Xmlurl.xml" > The data Island object mainly obtains some information of the XML file

Properties: Tagname-Gets the name of the label, which is the string "xml"

Text-Get all the data from the data island

Url-xml Absolute Path (only for an externally nested data island, you can use the URL to get the URL path and name to read the XML file)

2) The operation of the node

1: Root node

You can use the DocumentElement property to access the root element of the data island

Properties: Tagname--Gets the name of the label

Text--Get all the data in the data section except the label name

Getattribut--Gets the attribute value of the node, and if there are multiple properties, you can use the Attributes.item (index) method to get the property you want, starting with 0

2: Child nodes

You can use DocumentElement.childNodes.Item (Index) to access each child node.

(Note: Child nodes also have tagname and Text2 attribute access, meaning reference to the contents of the root node, in addition to the number of child nodes can be obtained by length)

Here is a simple example of XML that is displayed in HTML via the data island.

<学生管理>
<学生>
 <学号>97001
 <姓名>张三
 <性别>男
 <籍贯>浙江
<学生>
 <学号>97002
 <姓名>李四
 <性别>男
 <籍贯>浙江
<学生>
 <学号>97005
 <姓名>经典邂逅
 <性别>女
 <籍贯>广东

This XML is saved as Stu.xml, and the following HTML is placed under the same level folder

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.