Retrieve informations from XML in ASP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pheddy
    New Member
    • Dec 2008
    • 80

    Retrieve informations from XML in ASP?

    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
    Code:
    CreateObject("MSXML.DOMDocument")
    have worked with my initial testings.

    The XML:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <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:
    Code:
    <?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!
Working...