inchecksolution
11 Apr 2011, 02:36 PM
I have an XML file and here is the basic structure:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<transaction_id>q34f56fafsdferg35435g4eg</transaction_id>
<requested_at>2010-02-23 21:03:29</requested_at>
<method>market/active</method>
<markets>
<market>
<id>albany</id>
<city>Albany</city>
<state>New York</state>
<url>http://www.crowdsavings.com/albany</url>
<timezone>America/New_York</timezone>
<twitter>http://twitter.com/crowdsavings</twitter>
<facebook>http://www.facebook.com/home.php#!/pages/CrowdSavingscom-Albany-NY/103933489653928</facebook>
<latitude>42.652579</latitude>
<longitude>-73.756232</longitude>
</market>
<market>
<id>tampa</id>
<city>Tampa Bay</city>
<state>Florida</state>
<url>http://www.crowdsavings.com/tampa</url>
<timezone>America/New_York</timezone>
<twitter>http://twitter.com/crowdsavings</twitter>
<facebook>http://www.facebook.com/pages/CrowdSavingscom-Tampa-Bay/108944445798968</facebook>
<latitude>27.949436</latitude>
<longitude>-82.465144</longitude>
</market>
</markets>
</response>
The xml file is located at: https://www.crowdsavings.com/api/v2/market/active.xml
Can someone show me how (USING PHP) to load the XML document, loop through it and display a list of all the city's and states. For example, if you ran the code on the example above you would get:
Albany, New York
Tampa Bay, Florida.
I have an API key as it is require based on the documentation located at: http://www.crowdsavings.com/api/docs/v2 but I am not posting it for security reasons.
Thanks!
<?xml version="1.0" encoding="UTF-8"?>
<response>
<transaction_id>q34f56fafsdferg35435g4eg</transaction_id>
<requested_at>2010-02-23 21:03:29</requested_at>
<method>market/active</method>
<markets>
<market>
<id>albany</id>
<city>Albany</city>
<state>New York</state>
<url>http://www.crowdsavings.com/albany</url>
<timezone>America/New_York</timezone>
<twitter>http://twitter.com/crowdsavings</twitter>
<facebook>http://www.facebook.com/home.php#!/pages/CrowdSavingscom-Albany-NY/103933489653928</facebook>
<latitude>42.652579</latitude>
<longitude>-73.756232</longitude>
</market>
<market>
<id>tampa</id>
<city>Tampa Bay</city>
<state>Florida</state>
<url>http://www.crowdsavings.com/tampa</url>
<timezone>America/New_York</timezone>
<twitter>http://twitter.com/crowdsavings</twitter>
<facebook>http://www.facebook.com/pages/CrowdSavingscom-Tampa-Bay/108944445798968</facebook>
<latitude>27.949436</latitude>
<longitude>-82.465144</longitude>
</market>
</markets>
</response>
The xml file is located at: https://www.crowdsavings.com/api/v2/market/active.xml
Can someone show me how (USING PHP) to load the XML document, loop through it and display a list of all the city's and states. For example, if you ran the code on the example above you would get:
Albany, New York
Tampa Bay, Florida.
I have an API key as it is require based on the documentation located at: http://www.crowdsavings.com/api/docs/v2 but I am not posting it for security reasons.
Thanks!