Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.
I need to extract ALL information from an XML document in classic ASP. I have tried alot, but cant seem to find the best way to do this. Below theres an example of the XML document and its associated XSD document. My provider runs IIS 6.0 and using CreateObject("MSXML.DOMDocument") have worked with my initial testings.

The XML:
<products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="oemPriceXMLList.xsd">
<group name="">
</group>
<group name="Software">
<product id="50634">
<name>Adobe Premiere Elements UK V8</name>
<stock>Yes</stock>
<weight>0.5</weight>
<model>65045809</model>
<shortDescription>Adobe Premiere Elements - ( v. 8 )</shortDescription>
<manufacturerName>Adobe</manufacturerName>
<manufacturerURL>http://www.adobe.com/</manufacturerURL>
<price>475</price>
</product><product id="50635">
<name>Adobe Photoshop</name>
<stock>Yes</stock>
<weight>0.5</weight>
<model>65045041</model>
<shortDescription>Adobe Photoshop</shortDescription>
<manufacturerName>Adobe</manufacturerName>
<manufacturerURL>http://www.adobe.com/</manufacturerURL>
<price>479</price>
</product></group>


The XSD:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- definition of simple elements -->
<xs:element name="name" type="xs:string"/>
<xs:element name="price" type="xs:positiveInteger"/>
<xs:element name="stock" type="xs:string"/>
<xs:element name="weight" type="xs:decimal"/>
<xs:element name="model" type="xs:string"/>
<xs:element name="shortDescription" type="xs:string"/>
<xs:element name="manufacturerName" type="xs:string"/>
<xs:element name="manufacturerURL" type="xs:string"/>

<!-- definition of attributes -->
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="id" type="xs:positiveInteger"/>

<!-- definition of complex elements -->
<xs:element name="product">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="name"/>
      <xs:element ref="price"/>
      <xs:element ref="stock"/>
      <xs:element ref="weight"/>
      <xs:element ref="model"/>
      <xs:element ref="shortDescription"/>
      <xs:element ref="manufacturerName"/>
      <xs:element ref="manufacturerURL"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name="group">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="product"/>
    </xs:sequence>
    <xs:attribute ref="id" use="required"/>
  </xs:complexType>
</xs:element>

<xs:element name="products">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="group"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>


I beleieve the best way to get through this would be looping through each <product name="xxx"> AND THEN loop through each <product id="xxx"> and show its elements..
Dont know if this is correct? As I wrote I have tried ALOT and there for would be very glad if someone could guide me all the way through this one :D

Thanks!
Posted
Comments
Drew Scott 22-Dec-10 10:07am    
You could use XPath to identify each Software and then loop through the elements.

How did you want to display the results?

Could you provide your ASP code for reading the XML?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900