Wrox Programmer Forums
|
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2003, 08:35 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading XML through ASP

I have an XML document such as this one:

<Calls>
  <Call>
     <ID>93434</ID>
     <FirstName>John</FirstName>
     <LastName>Frank</LastName>
     <Phone>555-555-5555</Phone>
     <Country />
  </Call>
</Calls>

The problem is when the object Microsoft.XMLDOM trys to read the <Country /> tag, it gets an error. Below is the code that I use to read through the XML:
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.load Session("XmlResponseFile")
Set objLst = objXML.getElementsByTagName("Call")
    For i = 0 to objLst.Length - 1
        Set subLst = objLst.item(i)
        sCallNumber = subLst.childNodes(0)


Anyone have any ideas why I get the following error???

Error Message:
Microsoft VBScript runtime error '800a01a8'
Object required: 'subLst.childNodes(...).childNodes(...)'

/jstars/call_list.asp, line 42
 
Old September 13th, 2003, 02:16 AM
Authorized User
 
Join Date: Sep 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please use
     For i = 0 to objLst.childNodes.Length - 1
instead of
     For i = 0 to objLst.Length - 1

hope it helps
 
Old June 11th, 2010, 06:48 AM
Registered User
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Xml parsing with xml

Hi

I am using this script to fetch value with xml. With this script i am able to find link and desc but also i want to find out image_src and price from the xml. But i am helpless for this two. Below is the script i am using.

set xmlDocument = getXml("aminofile.xml")

xPath = "//RES/R"
set result = xmlDocument.selectNodes(xPath)
for each record in result
link = record.selectSingleNode("U").text
desc = record.selectSingleNode("S").text
imgage = record.selectSingleNode("PAGEMAP").childNodes(1).a ttributes.getNamedItem("IMAGE_SRC").nodeValue

response.write "<tr><td width='300'>"& link & "</td>"
response.write "<td width='300'>"& desc & "</td></tr>"
response.write imgage

next


and the xml is

<R N="5">
<U>
http://www.solgar.co.uk/modules/catb...minoAcids.html
</U>
<UE>
http://www.solgar.co.uk/modules/catb...minoAcids.html
</UE>

<T>
Solgar <b>Amino</b> Acids - Solgar Vitamins Health Store
</T>
<RK>0</RK>

<S>
<b>Amino</b> 75 30 Capsules 75 <b>amino</b> acid solgar, <b>amino</b>, <b>amino</b> acid Balanced free-form <br> <b>amino</b> acid formula, containing essential <b>amino</b> acids SUGAR, SALT AND STARCH <b>...</b>
</S>
<LANG>en</LANG>
<Label>_cse_x0qmgd4mgeu</Label>

<HAS>
<L/>
<C SZ="26k" CID="1tJ11047rU8J"/>
<RT/>
</HAS>
</R>
<RG START="6" SIZE="1"/>

<R N="6">

<U>
https://www.solgar.co.uk/modules/sho...?prodcode=E162
</U>

<UE>
https://www.solgar.co.uk/modules/sho...rodcode%3DE162
</UE>

<T>
ArginineOrnithine 250 Vegicaps Discontinued by Solgar <b>Amino</b> Acids <b>...</b>
</T>
<RK>0</RK>

<S>
Arginine-Ornithine 250 Vegicaps - Discontinued by Solgar - LArginineLOrnithine <br> 500250 mg Vegicaps (Free Form)SUGAR, SALT AND STARCH FREE SUITABLE FOR <b>...</b>
</S>
<LANG>en</LANG>
<Label>_cse_x0qmgd4mgeu</Label>

<PageMap>

<DataObject type="image">
<Attribute name="image_src" value="http://www.solgar.co.uk//modules/shop/images/LARGINI1.jpg"/>
</DataObject>

<DataObject type="publication">
<Attribute name="price" value="48.05"/>
</DataObject>
</PageMap>

<HAS>
<L/>
<C SZ="28k" CID="yuhb8N-q7MgJ"/>
<RT/>
</HAS>
</R>
 
Old June 11th, 2010, 07:02 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Consider to post the XML in well-formed and indented way, making use the forum's code block markup.
As far as I can see you want e.g.
Code:
imgSrc = record.selectSingleNode("PageMap/DataObject[@type = 'image']/Attribute[@name = 'image_src']/@value").nodeValue
price = record.selectSingleNode("PageMap/DataObject[@type = 'publication']/Attribute[@name = 'price']/@value").nodeValue
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading XML file using ASP itHighway Classic ASP XML 1 June 7th, 2006 06:16 AM
Reading XML file using ASP itHighway Classic ASP Basics 1 May 1st, 2006 06:21 PM
Reading XML file using ASP itHighway XSLT 2 April 29th, 2006 04:52 AM
Reading XML string using asp itHighway Classic ASP XML 2 March 10th, 2005 11:54 PM
Reading XML from ASP texasraven Classic ASP XML 2 February 26th, 2004 03:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.