loadXML Method
Loads an XML document using the supplied string.
boolValue = oXMLDOMDocument.loadXML(xmlString)
Parameters
xmlString
String containing the XML string to load into this XML document object. This string can contain an entire XML document or a well-formed fragment.
Return Value
Boolean. Returns True if the XML load succeeded. Returns False and sets the DOMDocument object's documentElement property to Null if the XML load failed.
Remarks
Calling load or loadXML on an existing document immediately discards the content of the document.
This member is an extension of the W3C DOM.
Example
The following VBScript example creates a DOMDocument object, and then uses its loadXML method to load the specified XML before displaying it:
Dim xmlDoc
Set xmlDoc = CreateObject("microsoft.xmldom")
xmlDoc.async = False
xmlDoc.loadXML("<customer><first_name>Joe</first_name><last_name>Smith</last_name></customer>")
MsgBox (xmlDoc.xml)
See Also
Applies To: DOMDocument Object | XML DOM Persistence
<%
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(server.mappath("testXML.xml"))
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(server.mappath("testXSL.xsl"))
Response.Write(xml.transformNode(xsl))
%>
对照这个例子,我们主要来讲一下 testXML.asp 文件
set xml = Server.CreateObject("Microsoft.XMLDOM")
set xsl = Server.CreateObject("Microsoft.XMLDOM")
用来分别创建一个xml和xsl的实例,其中xml.load(server.mappath("testXML.xml"))用来加载
包含数据的xml文件,xsl.load(server.mappath("testXSL.xsl"))用来加载包含数据规则的xsl
文件,最终利用xml.transformNode(xsl)将前面的规则使用在XML文件中。