Welcome to WebmasterWorld Guest from 50.19.34.255

Forum Moderators: open

Message Too Old, No Replies

XML/ASP shot in the dark

parsing XML using ASP

     
11:38 am on Oct 17, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:May 23, 2002
posts: 446
votes: 0


Hi

A shot in the dark here. I've been struggling to parse an XML response using "Classic" ASP. Apologies for using wrong terminology.

The XML starts like this:

<?xml version="1.0" encoding="UTF-8"?>

-<OTA_VehAvailRateRS TimeStamp="2014-10-08T14:01:04.271+01:00" PrimaryLangID="EN" Target="Production" Version="2.004" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_VehAvailRateRS.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opentravel.org/OTA/2003/05">

<Success/>


-<VehAvailRSCore>


-<VehRentalCore ReturnDateTime="2014-10-31T10:00:00Z" PickUpDateTime="2014-10-24T10:00:00Z">

<PickUpLocation Name="Grantley Adams - Airport" LocationCode="2418" CodeContext="XXX"/>

<ReturnLocation Name="Grantley Adams - Airport" LocationCode="2418" CodeContext="XXX"/>

</VehRentalCore>


-<VehVendorAvails>


-<VehVendorAvail>

<Vendor CodeContext="XXX" Division="STOUTES" CompanyShortName="STOUTES" Code="45"/>


-<VehAvails>


-<VehAvail>


-<VehAvailCore Status="Available">


-<Vehicle CodeContext="XXX" Code="IFAR" BaggageQuantity="5" PassengerQuantity="5" DriveType="Unspecified" FuelType="Petrol" TransmissionType="Automatic" AirConditionInd="true">

<VehType DoorCount="5" VehicleCategory="3"/>

<VehClass Size="28"/>

<VehMakeModel Name="Ford Ecosport or similar" Code="IFAR"/>

<PictureURL>pic.jpg</PictureURL>

<VehIdentity VehicleAssetNumber="32349"/>

</Vehicle>


Using the following code:

<%  

Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
objXMLDoc.async = False
objXMLDoc.load Server.MapPath("2014 Oct 8 14 1 26VehAvailRatesRQRS.xml")


Dim objChildNodes, strNode
Set objChildNodes = objXMLDoc.documentElement.childNodes

For Each strNode In objChildNodes
Response.Write strNode.nodeName & "<br>"
Next

%>


All I get is the first "VehAvailRSCore"

I've trawled through many, many web pages with examples but none seem to handle that type of XML response. (they all have <NODE>date</NODE> which isn't the same as what I've got to go through, above).

Does anyone have any example code that I can use to extract the data from the XML example above?

Thanks

Mick
1:07 pm on Oct 17, 2014 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4061
votes: 0


Gosh Mick, It's been so long since I used "classic" ASP, last time I built anything with VBScript was 13 years ago... The syntax looks familiar - and correct - but I can't debug this for you.

From the XML sample you pasted above, it looks like there only is one "VehAvailRSCore" node, a child of the document root. I suppose you're expecting something otherwise, or the example you've given isn't complete?
1:33 pm on Oct 17, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:May 23, 2002
posts: 446
votes: 0


Hi httpwebwitch

Yes, 'classic' ASP. Stuck in time here working on a legacy system that's way too complicated to start reprogramming the whole thing. Adding the XML features will improve things somewhat.

I can just get that one node but I don't know the code/syntax to navigate down through the XML. Previously I wrote heaps of tedious code to go through the XML and extract the data but I thought that using that code would improve things and make development of new XML feeds faster.

Ah well, back to the drawing board.

Thanks, Mick