Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use XML DOM to Sort Document (Ex. uses VBScript)

Status
Not open for further replies.

haphols

Programmer
Feb 7, 2002
1
US
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=&quot;1.0&quot; ?>
<catalog>
<item id=&quot;1&quot;>
<type>Cotton</type>
<dyfast>0</dyfast>
</item>
<item id=&quot;2&quot;>
<type>Polyester</type>
<dyfast>1</dyfast>
</item>
<item id=&quot;3&quot;>
<type>Nylon</type>
<dyfast>1</dyfast>
</item>
</catalog>

Processing File: DisplayFile.xml
<%
Dim objXMLDom
Set objXMLDOM = Server.CreateObject(&quot;Microsoft.XMLDOM&quot;)
objXMLDOM.async = &quot;False&quot;
objXMLDom.load(Server.MapPath(&quot;XMLFile.xml&quot;))
set objChild = objXMLDOM.documentElement
%>
<TABLE BORDER=&quot;1&quot;>
<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 &quot;<TR>&quot;
set nextChild = objChild.childNodes(item)
for each itemdetail in nextChild.childNodes
response.write(&quot;<TD>&quot; & itemdetail.text & &quot;</TD>&quot;)
next
Response.Write &quot;</TR>&quot;
next

Set objXMLDom = Nothing
%>
</TABLE>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top