XMLSax Parsing Question

pixelpop

Active Member
Licensed User
Longtime User
In another thread, NJDude suggested this code for parsing in-line values in an XML file:

Code: Copy
Sub Parser_StartElement(Uri As String, Name As String, Attributes As Attributes)
   Msgbox("Uri=" & Uri & CRLF & "Name=" & Name & CRLF & "Attrib=" & Attributes.GetValue(2), "")
End Sub

I have a similar problem trying to parse an XML response in order to assign ArrivalDate to a variable. Here is my XML response to an HTTP query:

HTML: Copy
<?xml version="1.0" encoding="UTF-8"?>
 <FlightHistoryGetRecordsResponse xmlns="http://pathfinder-xml/FlightHistoryService.xsd">
 <FlightHistory DepartureAirportTimeZoneOffset="-8" ArrivalAirportTimeZoneOffset="-5" ArrivalDate="2013-01-29T22:15:00.000" ArrivalGate="D15" ArrivalTerminal="N">
 <Airline AirlineCode="AA" IATACode="AA" ICAOCode="AAL" Name="American Airlines"/><Origin AirportCode="LAS" FAACode="LAS" IATACode="LAS" ICAOCode="KLAS" Name="McCarran International Airport"/><Destination AirportCode="MIA" FAACode="MIA" IATACode="MIA" ICAOCode="KMIA" Name="Miami International Airport"/>
</FlightHistory>
</FlightHistoryGetRecordsResponse>

When I run NJDude's example, it returns "FlightHistoryGetRecordsResponse" as the Name, but never gets to the FlightHistory tag. ArrivalDate is the third value in the FlightHistory tag. Thanks!
 
I replaced:

Msgbox("Uri=" & Uri & CRLF & "Name=" & Name & CRLF & "Attrib=" & Attributes.GetValue(2), "")

with:

Msgbox("Uri=" & Uri & CRLF & "Name=" & Name & CRLF & "Attrib=" & Attributes.GetValue2("", "ArrivalDate"))

I get a compile error: Error description: Missing parameter.
 
Upvote 0
Back
Top