Hello - I am trying to use XML DOM with VBScript to sort and/or filter an XML document. I know I can use XSLT to Sort and Filter, but I want to work in any browser, which is why I thought using the DOM would be a better solution.
Is this possible? Below you will find sample data. Would I be able to sort by <type>, or filter out items where the <dyfast> element = 0
Sample data: XMLFile.xml
<?xml version="1.0" ?>
<catalog>
<item id="1">
<type>Cotton</type>
<dyfast>0</dyfast>
</item>
<item id="2">
<type>Polyester</type>
<dyfast>1</dyfast>
</item>
<item id="3">
<type>Nylon</type>
<dyfast>1</dyfast>
</item>
</catalog>
Processing File: DisplayFile.xml
<%
Dim objXMLDom
Set objXMLDOM = Server.CreateObject("Microsoft.XMLDOM"
objXMLDOM.async = "False"
objXMLDom.load(Server.MapPath("XMLFile.xml")
set objChild = objXMLDOM.documentElement
%>
<TABLE BORDER="1">
<TR>
<TH>Type</TH>
<TH>SubType</TH>
<TH>Brand</TH>
<TH>Color</TH>
<TH>DyFast</TH>
</TR>
<%
for item = 0 to objChild.childNodes.length-1
Response.Write "<TR>"
set nextChild = objChild.childNodes(item)
for each itemdetail in nextChild.childNodes
response.write("<TD>" & itemdetail.text & "</TD>"
next
Response.Write "</TR>"
next
Set objXMLDom = Nothing
%>
</TABLE>
Is this possible? Below you will find sample data. Would I be able to sort by <type>, or filter out items where the <dyfast> element = 0
Sample data: XMLFile.xml
<?xml version="1.0" ?>
<catalog>
<item id="1">
<type>Cotton</type>
<dyfast>0</dyfast>
</item>
<item id="2">
<type>Polyester</type>
<dyfast>1</dyfast>
</item>
<item id="3">
<type>Nylon</type>
<dyfast>1</dyfast>
</item>
</catalog>
Processing File: DisplayFile.xml
<%
Dim objXMLDom
Set objXMLDOM = Server.CreateObject("Microsoft.XMLDOM"
objXMLDOM.async = "False"
objXMLDom.load(Server.MapPath("XMLFile.xml")
set objChild = objXMLDOM.documentElement
%>
<TABLE BORDER="1">
<TR>
<TH>Type</TH>
<TH>SubType</TH>
<TH>Brand</TH>
<TH>Color</TH>
<TH>DyFast</TH>
</TR>
<%
for item = 0 to objChild.childNodes.length-1
Response.Write "<TR>"
set nextChild = objChild.childNodes(item)
for each itemdetail in nextChild.childNodes
response.write("<TD>" & itemdetail.text & "</TD>"
next
Response.Write "</TR>"
next
Set objXMLDom = Nothing
%>
</TABLE>