P pixelpop Active Member Licensed User Longtime User Jan 30, 2013 #1 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!
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!
Erel B4X founder Staff member Licensed User Longtime User Jan 30, 2013 #2 The value you are looking for the value in Attributes.GetValue2("", "ArrivalDate"). Upvote 0
P pixelpop Active Member Licensed User Longtime User Jan 30, 2013 #3 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
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.
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2013 #4 Because Msgbox expects an additional parameter for the title. I recommend you to use Log instead of Msgbox for such tasks. Upvote 0
Because Msgbox expects an additional parameter for the title. I recommend you to use Log instead of Msgbox for such tasks.