May 10, 201313 yr An API has been set up by someone else which provides an XML response. So if I send it GET values like a date or price, it returns different things from a database in XML. Which is something like this: http://www.domain.com/cgi-bin/cruise/get.cgi?shipid=1&cruise_month=6 The XML I see is something like: <cruise> <lineid>17</lineid> <linename>Princess</linename> <shipid>11</shipid> </cruise> The XML response I see is of course on "domain.com". How can I get this on to my site?? I have been told I need to parsing. Any tips?? Thanks
May 10, 201313 yr Could you be more specific about the data being returned - is it just one or multiple sets of information about cruises? Probably the simplest would be to use simplexml and then parse through it with a foreach loop.
May 10, 201313 yr As Gadgetgirl has said use simplexml, assuming you are running PHP of course. Then just loop through each element of the xml. Without more info about the data being returned a more specific answer is difficult to offer. More here.... http://php.net/manual/en/book.simplexml.php Your link just throws a 404 by the way. Edited May 10, 201313 yr by GalaxyTramp
May 20, 201313 yr Hopefully a recent XML blog post of mine can be of help. Seems your looking at cURL to connect to the external XML file then load its content into a variable to then use SimpleXML to parse it. http://jordancharters.co.uk/blog/writing-a-web-service-client/
May 29, 201313 yr As per the above and JordanC's rather apt tutorial I would use simpleXML, although as opposed to using cURL you can/could simply use the function shown in the tutorial simplexml_load_file() and insert your appropriate URI to the api and avoid the use of cURL entirely as it would be unnecessary. http://php.net/manual/en/function.simplexml-load-file.php
Create an account or sign in to comment