What is XMLObject() anyway?
This object handles all the repetitive and sometimes cumbersome operations necessary when developing with XML and XSLT.
For example, when you want to write the output of a transformation to the client, you'll need to do something like this:
- Create two instances of
MSXML2.DOMDocument(or other XMLParser Objects available). - Set the .async property for both objects to "false"
- Load the XML document into one object, and the XSL StyleSheet into the other.
- Perform the transformation and write the result to the output stream.
Usually looks something like this:
<%
var oXML = Server.CreateObject("MSXML2.DOMDocument");
var oXSL = Server.CreateObject("MSXML2.DOMDocument");
oXML.async = false;
oXSL.async = false;
oXML.load(Server.MapPath("links.xml"));
oXSL.load(Server.MapPath("transform.xsl"));
var oHTML = oXML.transformNode(oXSL);
Response.Write(oHTML);
%>
When using XMLObject() all of this is handled automatically, but there's more:
- You don't need the Server.MapPath() — just the filename or:
- Alternatively, you can specify an XMLstring instead of a filename, which effectively creates a new XMLDocument
- You can take advantage of caching-mechanisms, boosting performance
- You can send QueryString parameters directly into the StyleSheet as easy as you pass them to your regular ASP pages