Recommended: How to convert ASP dynamic web pages into HTM static pages Some time ago, an asp page was very slow to execute, with a lot of visitors, and it was not modified frequently, so it was too lazy to directly make it into static. Every time I had to download it from the server to modify it, I had to find a way to convert the asp page into an htm static page. I've seen such a text before
NO.1--Create an XML database data.xml
| <?xml version=1.0?> <records> <record> <name>caca</name> <qq>1542222225</qq> <email>[email protected]</email> </record> <records> |
NO.2--Create object CreateObject
Create data.xml object first
| set xmldoc=server.createobjcet(microsoft.xmldom) xmldoc.load(server.mappath(data.xml) |
NO.3--Select Node
Which Node do you want to operate? Do you have to locate this node? Let’s first look at how many Nodes there are in this data.xml?
Use a recursive function to do it:
getnodes(xmldoc) sub getnodes(node) dim i response.write(<br><b>NodeName:</b>&node.nodename&<br><b>NodeTypeString:</b>&node.nodetypestring&<br><b>NodeValue:</b>&node.nodevalue&<br><b>Text:</b>&node.text&<br><b>node.childnodes.length:</b>&node.childnodes.length&<p>) if node.childnodes.length<>0 then for i=0 to node.childnodes.length-1 getnodes(node.childnodes(i)) next end if end sub |
After using this function, you can see that this data.xml has 10 Nodes
These Nodes can be positioned very simply:
| xmldoc.childnodes(0) xmldoc.childnodes(1) xmldoc.childnodes(1).childnodes(0) xmldoc.childnodes(1).childnodes(0).childnodes(0) xmldoc.childnodes(1).childnodes(0).childnodes(0).text xmldoc.childnodes(1).childnodes(0).childnodes(1) xmldoc.childnodes(1).childnodes(0).childnodes(1).text xmldoc.childnodes(1).childnodes(0).childnodes(2) xmldoc.childnodes(1).childnodes(0).childnodes(2).text |
Is positioning very simple? There is another method, such as positioning <name>
xmldoc.selectsinglenode(//name)
NO.4--assign a value to a node (modify the value of the node)
After learning to locate nodes and use their attributes, you can modify or assign values.
For example, change the value of <name> caca to wawa
xmldoc.selectsinglenode(//name).text=wawa CuoXIn.Com xmldoc.save(server.mappath(data.xml)) |
Get it done!
NO.5--CreatenewNode
Use createelement or createnode(,,)
For example: Create a new <age> under record, and it takes only one sentence to do it:
xmldoc.selectsinglenode(//record).appendchild(xmldoc.createelement(<age>))
Assign a value to <age>
| xmldoc.selectsinglenode(//age).text=20 xmldoc.save(server.mappath(data.xml)) |
Get it done!
NO.6--DeleteNode
You must clarify the parent node of the node you want to delete and the characteristics of the node
For example: Delete the <qq> node
| xmldoc.selectsinglenode(//record).removechild(xmldoc.selectsinglenode(//qq)) |
For example: delete the <name>=caca's <record>
| xmldoc.selectsinglenode(//records).removechild(xmldoc.selectsinglenode(//record[name='caca'])) xmldoc.save(server.mappath(data.xml)) CuoXIn.Com |
Get it done!
Only by being able to proficient in these 6 codes and using Asp to control the XML database will be almost done...
Share: Use styles, themes, and skins in ASP.NET 2.0 The theme and skin features of ASP.net2.0 enable you to store style and layout information in a separate set of files, collectively called Theme. Next we can apply this topic to any site to change the appearance and feel of pages and controls within that site. Pass