Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 20th, 2003, 08:35 AM
Registered User
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old September 13th, 2003, 02:16 AM
Authorized User
 
Join Date: Sep 2003
Location: , , .
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
Reply With Quote
  #3 (permalink)  
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>
Reply With Quote
  #4 (permalink)  
Old June 11th, 2010, 07:02 AM
Friend of Wrox
Points: 6,420, Level: 34
Points: 6,420, Level: 34 Points: 6,420, Level: 34 Points: 6,420, Level: 34
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,194
Thanks: 0
Thanked 236 Times in 235 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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 10:54 PM
Reading XML from ASP texasraven Classic ASP XML 2 February 26th, 2004 02:26 PM



All times are GMT -4. The time now is 02:20 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.