Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the 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 Search this Thread Display Modes
  #1 (permalink)  
Old September 22nd, 2004, 08:39 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parsing xml datastream using XMLDOM

I am getting an error when trying to parse for one field in a returned response from an outside source.

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/cart/newcart/checkitOUT.asp, line 61

Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.

Any ideas on this?


My Code:
Dim xml2
Set xml2 = server.createobject("Mircosoft.XMLDOM")
xml2.async = false
xml2.load strRetVal
Dim STANDARDGROUNDTOTAL
STANDARDGROUNDTOTAL = xml2.documentElement.childnodes(11).text
set xml2 = nothing



Reply With Quote
  #2 (permalink)  
Old September 22nd, 2004, 08:53 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

I think Mircosoft should be Microsoft.

HTH,

Chris

Reply With Quote
  #3 (permalink)  
Old September 22nd, 2004, 09:08 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops ... If it only was that simple. Changed the typo but now I get:

Microsoft VBScript runtime (0x800A01A8)
Object required: 'documentElement'

I am thinking that this has something to do with .load method not containing an actual physical file like xml.load(server.mappath(example.xml). At the moment I am trying to insert the response (strRetVal) into the xml.load (strRetVal).

Reply With Quote
  #4 (permalink)  
Old September 22nd, 2004, 09:11 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you are loading a string, you need loadXML(), not load()

Cheers,

Chris

Reply With Quote
  #5 (permalink)  
Old September 22nd, 2004, 09:13 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by ChrisScott
 Hi,

I think Mircosoft should be Microsoft.

HTH,

Chris
Well personally I think the Mircosoft products are very good:)

On a serious note here is some advice from another post:

When asked for a DomDocument IE gives the latest version upto version 2.6 or version 3 if installed in replace mode. See MSDN - XML for more details if you wish. If you are sure that parser version 3 is available you are better off creating your own parser when needed:


var oStyle = new ActiveXObject("Msxml2.DomDocument.3.0");
oStyle.async = false;
oStyle.setProperty("SelectionLanguage", "XPath");
oStyle.load(xslBook.XMLDocument);


If you know version 4 is available then use that:


var oStyle = new ActiveXObject("Msxml2.DomDocument.4.0");
oStyle.async = false;
oStyle.load(xslBook.XMLDocument);





--

Joe (Co-author Beginning XML, 3rd edition)
Reply With Quote
  #6 (permalink)  
Old September 22nd, 2004, 10:22 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help. The xmlLoad was the fix.

Reply With Quote
  #7 (permalink)  
Old September 23rd, 2004, 07:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi realgone,

since your other questions have been about serverxmlhttp, I was wondering whether in this code you were trying to load the response from a serverxmlhttp call into a dom. If yes, then you should be aware that there's no need to get the response in string format and then load it into a dom, the responseXML property is a dom already, so you could just do
Code:
Set xml2 = yourxmlhttp.responseXML
rgds
Phil
Reply With Quote
  #8 (permalink)  
Old September 23rd, 2004, 08:07 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Phil,
Ah ha ... Have a look at my complete script is there redundancy here?
It works so I am not complaining at this point.


<%
Dim PostData
Dim xml
Dim objXMLHTTP

PostData = PostData & "requestid=" & Request.Form("requestid") & ""
PostData = PostData & "&"
PostData = PostData & "originzip=" & Request.Form("originzip") & ""
PostData = PostData & "&"
PostData = PostData & "destzip=" & Request.Form("destzip") & ""
PostData = PostData & "&"
PostData = PostData & "weight0=" & Request.Form("weight0") & ""
PostData = PostData & "&"
PostData = PostData & "pieces0=" & Request.Form("pieces0") & ""
PostData = PostData & "&"
PostData = PostData & "shipClass0=" & Request.Form("shipClass0") & ""
PostData = PostData & "&"
PostData = PostData & "ltldd=" & Request.Form("ltldd") & ""
PostData = PostData & "&"
PostData = PostData & "payment=" & Request.Form("payment") & ""
PostData = PostData & "&"
PostData = PostData & "weight1=" & Request.Form("weight1") & ""
PostData = PostData & "&"
PostData = PostData & "pieces1=" & Request.Form("pieces1") & ""
PostData = PostData & "&"
PostData = PostData & "shipClass1=" & Request.Form("shipClass1") & ""
PostData = PostData & "&"
PostData = PostData & "weight2=" & Request.Form("weight2") & ""
PostData = PostData & "&"
PostData = PostData & "pieces2=" & Request.Form("peices2") & ""
PostData = PostData & "&"
PostData = PostData & "shipClass2=" & Request.Form("shipClass2") & ""
PostData = PostData & "&"
PostData = PostData & "weight3=" & Request.Form("weight3") & ""
PostData = PostData & "&"
PostData = PostData & "pieces3=" & Request.Form("pieces3") & ""
PostData = PostData & "&"
PostData = PostData & "shipClass3=" & Request.Form("shipClass3") & ""
PostData = PostData & "&"
PostData = PostData & "weight4=" & Request.Form("weight4") & ""
PostData = PostData & "&"
PostData = PostData & "pieces4=" & Request.Form("pieces4") & ""
PostData = PostData & "&"
PostData = PostData & "shipClass4=" & Request.Form("shipClass4") & ""

set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.open "GET", "https://www.yahoo.com&" _
& PostData & "", False, _
"usr","pwd"
xml.SetRequestHeader "Content-type", "application/xx-www-form-urlencoded"
xml.send ""
strStatus = xml.Status
strRetval = xml.responseText
set xml = nothing

Dim xml2
Set xml2 = Server.CreateObject("Msxml2.DomDocument.4.0")
xml2.async = false
xml2.loadXML strRetVal
Dim STANDARDGROUNDTOTAL
STANDARDGROUNDTOTAL = xml2.documentElement.childnodes(16).text
set xml2 = nothing

%>

Reply With Quote
  #9 (permalink)  
Old September 23rd, 2004, 08:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Since you ask ;)

1. set xml = Server.CreateObject("Microsoft.XMLHTTP")
try this with "MSXML2.ServerXMLHTTP.4.0"

2. You don't really need the xml2 object at all, you could change
strStatus = xml.Status
strRetval = xml.responseText
set xml = nothing

Dim xml2
Set xml2 = Server.CreateObject("Msxml2.DomDocument.4.0")
xml2.async = false
xml2.loadXML strRetVal
Dim STANDARDGROUNDTOTAL
STANDARDGROUNDTOTAL = xml2.documentElement.childnodes(16).text
set xml2 = nothing

to
Dim STANDARDGROUNDTOTAL
If xml.status = 200 Then
    STANDARDGROUNDTOTAL = xml.responseXML.documentElement.childnodes(16).tex t
End If
Set xml = Nothing

3. a more general point. The way you're getting the STANDARDGROUNDTOTAL out of the xml will be very sensitive to changes in the order of the returned xml - personally I use the selectSingleNode method. Also you should test that the node you expect actually exists before trying to extract its .text property. Something like this:
Set docElem = xml.responseXML.documentElement
If docElem Is Nothing Then
    ' unexpected XML format received - take some action
Else
    Set nodeYouWant = docElem.selectSingleNode("<<path to node here>>")
    If nodeYouWant Is Nothing Then
        ' unexpected XML format received - take some action
    Else
        STANDARDGROUNDTOTAL = nodeYouWant.text
    End If
End If

rgds
Phil
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Parsing the xml which is having vikkiefd XML 14 July 28th, 2008 05:21 AM
parsing xml kri_hegde XML 5 July 24th, 2007 11:37 AM
Javascript and using the XMLDOM to modify xml TheNinthPlayer Javascript 1 January 5th, 2005 05:56 AM
Reading XML datastream realgone_ Classic ASP XML 5 September 22nd, 2004 01:17 PM
Reading XML datastream returned from vendor marabunta Classic ASP XML 1 September 8th, 2003 09:23 AM



All times are GMT -4. The time now is 03:10 PM.


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