Hello
I am not really sure since I am not that experienced with xml on how to turn it into an array then loop through the array to display each event. I am able to get the info and display the xml but converting it to an array is where my brain goes to mush 🙂 Any help would be appericated on how to accomplish this. Here is what I have so far.
$web_query = "http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=<TrackRequest%20USERID=\"" . $_POST['web_id'] . "\"><TrackID%20ID=\"" . trim($_POST['web_track']) . "\"></TrackID></TrackRequest>";
//Run the query
//temporarly disable query
$API_results = file_get_contents($web_query);
//Display results using htmlentities becuase results of the web query come across as a string with no values
echo "Response is <BR><BR> " . htmlentities($API_results) . "<BR><BR>";
/* The above echo displays the following results */
<?xml version="1.0"?>
<TrackResponse>
<TrackInfo ID="420331549101805213907654229389">
<TrackSummary>Your item was delivered at 11:57 am on May 14, 2008 in MIAMI BEACH, FL 33154.</TrackSummary>
<TrackDetail>Arrival at Unit, May 14, 2008, 7:12 am, MIAMI BEACH, FL 33154</TrackDetail>
<TrackDetail>Processed, May 12, 2008, 10:24 pm, BETHPAGE, NY 11714</TrackDetail>
<TrackDetail>Electronic Shipping Info Received, May 12, 2008</TrackDetail>
</TrackInfo>
</TrackResponse>
//Display results not using htmlentities results come across as string
echo("<br><br>$API_results");
/ * The above echo without htmlentities displays the following results */
Your item was delivered at 11:57 am on May 14, 2008 in MIAMI BEACH, FL 33154.Arrival at Unit, May 14, 2008, 7:12 am, MIAMI BEACH, FL 33154Processed, May 12, 2008, 10:24 pm, BETHPAGE, NY 11714Electronic Shipping Info Received, May 12, 2008 Response is
$web_query = "http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=<TrackFieldRequest%20USERID=\"" . $_POST['web_id'] . "\"><TrackID%20ID=\"" . trim($_POST['web_track']) . "\"></TrackID></TrackFieldRequest>";
//Run the query
//temporarly disable query
$API_results = file_get_contents($web_query);
//Display results using htmlentities becuase results of the web query come across as a string with no values
echo "Response is <BR><BR> " . htmlentities($API_results) . "<BR><BR>";
/* The above echo displays the following response */
<?xml version="1.0"?>
<TrackResponse>
<TrackInfo ID="420331549101805213907654229389">
<TrackSummary>
<EventTime>11:57 am</EventTime>
<EventDate>May 14, 2008</EventDate>
<Event>Delivered</Event>
<EventCity>MIAMI BEACH</EventCity>
<EventState>FL</EventState>
<EventZIPCode>33154</EventZIPCode>
<EventCountry/>
<FirmName/>
<Name/>
<AuthorizedAgent/>
</TrackSummary>
<TrackDetail>
<EventTime>7:12 am</EventTime>
<EventDate>May 14, 2008</EventDate>
<Event>Arrival at Unit</Event>
<EventCity>MIAMI BEACH</EventCity>
<EventState>FL</EventState>
<EventZIPCode>33154</EventZIPCode>
<EventCountry/>
<FirmName/>
<Name/>
<AuthorizedAgent/>
</TrackDetail>
<TrackDetail>
<EventTime>10:24 pm</EventTime>
<EventDate>May 12, 2008</EventDate>
<Event>Processed</Event>
<EventCity>BETHPAGE</EventCity>
<EventState>NY</EventState>
<EventZIPCode>11714</EventZIPCode>
<EventCountry/>
<FirmName/>
<Name/>
<AuthorizedAgent/>
</TrackDetail>
<TrackDetail>
<EventTime>2:46 pm</EventTime>
<EventDate>May 12, 2008</EventDate>
<Event>Electronic Shipping Info Received</Event>
<EventCity>NEW HYDE PARK</EventCity>
<EventState>NY</EventState>
<EventZIPCode>11040</EventZIPCode>
<EventCountry/>
<FirmName/>
<Name/>
<AuthorizedAgent/>
</TrackDetail>
</TrackInfo>
</TrackResponse>
//Display results not using htmlentities results come across as string
echo("<br><br>$API_results");
/* The above echo displays the following response */
11:57 amMay 14, 2008DeliveredMIAMI BEACHFL331547:12 amMay 14, 2008Arrival at UnitMIAMI BEACHFL3315410:24 pmMay 12, 2008ProcessedBETHPAGENY117142:46 pmMay 12, 2008Electronic Shipping Info ReceivedNEW HYDE PARKNY11040
}
What I am wanting to do is take each htmlentities response which is the xml and convert it to an array so I can do a for each loop.
If you know of another way of doing this I could use the suggestions.
Thanks