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