Books. asp
<%
''Create an XML Object
Set objxmldom = server. Createobject ("Microsoft. xmldom ")
''Specifies whether the XML file download is asynchronous with the XML Processing
Objxmldom. async = false
''To get the Directory and file name of the XML file. Here is the virtual directory.
Filestr = server. mappath ("./") & "/books. xml"
''Load the XML file
Objxmldom. Load (filestr)
''To get the length of the subnode
''Nodeslength = objxmldom. documentelement. childnodes. Length
''Response. Write (nodeslength & "<br> ")
'Get the parent node object
'Set parentnodes = objxmldom. documentelement
Set parentnodes = objxmldom.doc umentelement. selectsinglenode ("// books ")
'Get the length of the subnode
Childnodeslength = parentnodes. childnodes. Length
'Length of the output subnode
Response. Write ("Number of subnodes:" & parentnodes. childnodes. length)
Response. Write ("<br> ")
'Traverse the attributes and nodes of the subnode
For I = 0 to childNodesLength-1
Set objchile = parentnodes. childnodes (I)
Response. Write (I + 1 & ": bookid =" & objchile. getattribute ("ID "))
Response. Write (", sortid =" & objchile. getattribute ("sortid "))
Response. Write (", Title =" & objchile. selectsinglenode ("title"). Text)
Response. Write (", author =" & objchile. selectsinglenode ("author"). Text)
Response. Write (", <a href =" "javascript: removechilenode (" & I & ")"> Delete </a> ")
Response. Write (", <a href =" "javascript: editchilenode (" & I & ")"> edit </a> <br> ")
Next
Set objxmldom = nothing
%>
<SCRIPT>
Function removechilenode (ID)
{
If (! Confirm ("are you sure you want to delete the" + ID + "data nodes? ") Return false;
Location. href = 'delxmlchildnode. asp? Id = '+ ID;
}
Function editchilenode (ID)
{
Location. href = 'editbook. asp? Id = '+ ID;
}
</SCRIPT>
Books. xml
<? XML version = "1.0" encoding = "gb2312"?>
<Books>
<Book id = "4" sortid = "A4">
<Title> author4aa </title>
<Author> author4 </author>
</Book>
<Book id = "5" sortid = "A5">
<Title> author55 </title>
<Author> author5 </author>
</Book>
<Book id = "6" sortid = "A6">
<Title> booktitle </title>
<Author> author6 </author>
</Book>
</Books>