Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Parsing XML Response

Featured Replies

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

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.

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 by GalaxyTramp

You can also parse that XML through a javascript function...

  • 2 weeks later...

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.