When you create a new document in ASP, the new document will not automatically indent, although new documents are well formatted or effective from document content, all documents are in one line, using a notebook or other editing work open new When the file, the browsing file is very inconvenient. The following provides two solutions to the XML in ASP: 1. Ind retransmission formatted using XSL: XSL file:
XML Version = "1.0"?>
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------ ASP: <% DIM Xmldoc, Xsldoc, Resultdodim Node, SubnodeEt Xmldoc = Server.createObject ("msxml2.domdocument") xmldoc.async = falsexmldoc.loadxml (" xml version = '1.0' encoding = 'UTF-8'?>
'---------------------- Create a node * start -------------------- SET node = xmldoc.createElement ( "user") set subnode = xmldoc.createElement ( "name") subnode.text = "ssm1226" node.appendChild subnodeset subnode = xmldoc.createElement ( "nickname") subnode.text = "rain man" Node.Appendchild Subnode Subnode = NothingXMLDoc.documentelement.AppendChild NodeSet Node = Nothing '---------------------- Create node * end -------- -------------- SET XSLDOC = Server.createObject ("msxml2.domdocument") xsldoc.async = falsexsldoc.Load Server.mappath ("Transform.xsl") 'Loading Translation XSL File SET resultdoc = server.CreateObject ( "MSXML2.DOMDocument") resultdoc.async = falsexmldoc.transformNodeToObject xsldoc, resultdoc 'conversion set node = resultdoc.createProcessingInstruction ( "xml", "version =' 1.0 'encoding =' utf-8 '") 'Create Xml version =' 1.0 'encoding =' uTF-8 '?> Declaration Resultdoc.insertbefore Node, Resultdoc.FirstChild' Add Declaration Set Node = NothingResultdoc.save Server.mappath ("Result.xml") 'Save XML file%>
2. Add a chamber to Dom
<% Dim xmldoc, node1, node2set xmldoc = server.CreateObject ( "msxml2.domdocument") xmldoc.async = falsexmlDoc.validateOnParse = falseif not xmldoc.loadXML ( "
Response.write xmldoc.xmlresponse.endset node1 = xmldoc.createtextNode (VBCRLF)
Set node2 = xmldoc.createElement ("name") node2.text = "ssm1226"
XMLDoc.documentelement.appendchild node1.clonenode (true) xmldoc.documentelement.appendchild node2Xmldoc.documentelement.Appendchild Node1.clonenode (TRUE)
Xmldoc.save "c: /test.xml"%>