Ajax basics: briefly introduces how to use data islands

Source: Internet
Author: User
Data island refers to the XML in the HTML webpage. Code Segment, which forms a data set in HTML. Data island allows us to integrate XML into HTML webpages,
Write scripts for XML.
Data island has its own form. It starts with the tag XML and must have an id attribute in the start tag to specify the name of the specified data island. (Of course, use/XML
End). The content contained in element XML is the XML code. Data islands are also divided into two types:
1) embedded data island form
2) data island forms embedded outside
After talking so much nonsense, we still need to understand how to access and operate data island nodes. After all, we need to pay attention to using XML in HTML. Go
Subject:
Because of the attribute structure of data island, accessing data island is similar to accessing document objects. XML document objects refer to objects with attributes and methods.
And methods to access and process XML documents. When an XML data island is read and parsed, an XML document object is created.
1) Data island object
You can use the id value in <XML id = "xmlname" src = "xmlurl. xml"> to create a data island object. The data island object mainly obtains information about the XML file.
Attribute: tagname-get the tag name, that is, the string "XML"
Text-Get all data in data island
Absolute URL-XML Path (the URL can be used to obtain the URL path and name for reading the XML file only for the data island embedded outside)
2) node operations
1: Root Node
You can use the documentelement attribute to access the root element of the data island.
Attribute: tagname -- get the Tag Name
Text -- get all data except the tag name in the Data Section
Getattribut -- get the node attribute value. If there are multiple attributes, you can use the attributes. Item (INDEX) method to obtain the required attribute,
Starting from 0
2: subnode
You can use documentelement. childnodes. Item (INDEX) to access each subnode.
(Note: The subnode also has tagname and text2 attribute access. For more information, see the content of the root node. In addition, you can use length to obtain the number of subnodes)
The following is a simple example. XML is displayed in HTML through data island.


         
<Student Management>
<Student>
<Student no.> 97001 student no.>
<Name> name of Michael Zhang>
<Gender> male gender>
<Nationality> Zhejiang nationality>
Student>
<Student>
<Student no.> 97002 student no.>
<Name> Li Si Name>
<Gender> male gender>
<Nationality> Zhejiang nationality>
Student>
<Student>
<Student no.> 97005 student no.>
<Name> classic Name>
<Gender> female gender>
<Nationality> Guangdong nationality>
Student>
Student Management>

Save the XML as Stu. xml and put the following HTML in the same level folder.
The following uses an external data island to display XML files.


         
          
<HTML> 

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.