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.

getting data from xml feed

Featured Replies

I'd like to use some data from an xml feed but I don't know how to travel through the tree structure. For each [item], I want to get the title, link, pubDate and description. The only way I could think of is using a number of nested foreach loops, but is there a better way? Thanks

 

Below is an extract of the feed

SimpleXMLElement Object
(
[@attributes] => Array
 (
	 [version] => 2.0
 )
[channel] => SimpleXMLElement Object
 (
	 [title] => Intelligent Travel
	 [link] => http://intelligenttravel.nationalgeographic.com
	 [description] => Cultural, Authentic & Sustainable
	 [lastBuildDate] => Fri, 12 Oct 2012 18:42:06 +0000
	 [language] => en
	 [generator] => http://wordpress.org/?v=3.3.3
	 [item] => Array
		 (
			 [0] => SimpleXMLElement Object
				 (
					 [title] => How to Shoot the Milky Way…On Easter Island
					 [link] => http://intelligenttravel.nationalgeographic.com/2012/10/19/how-to-shoot-the-milky-way-on-easter-island/
					 [comments] => http://intelligenttravel.nationalgeographic.com/2012/10/19/how-to-shoot-the-milky-way-on-easter-island/#comments
					 [pubDate] => Fri, 19 Oct 2012 16:04:13 +0000
					 [category] => Array
						 (
							 [0] => SimpleXMLElement Object
								 (
								 )
							 [1] => SimpleXMLElement Object
								 (
								 )
							 [2] => SimpleXMLElement Object
								 (
								 )
							 [3] => SimpleXMLElement Object
								 (
								 )

						 )
					 [guid] => http://intelligenttravel.nationalgeographic.com/?p=35333
					 [description] => SimpleXMLElement Object
						 (
						 )
				 )
			 [1] => SimpleXMLElement Object
				 (
					 [title] => #FriFotos: Sit Down
					 [link] => http://intelligenttravel.nationalgeographic.com/2012/10/19/frifotos-sit-down/
					 [comments] => http://intelligenttravel.nationalgeographic.com/2012/10/19/frifotos-sit-down/#comments
					 [pubDate] => Fri, 19 Oct 2012 15:06:35 +0000
					 [category] => Array
						 (
							 [0] => SimpleXMLElement Object
								 (
								 )
							 [1] => SimpleXMLElement Object
								 (
								 )
							 [2] => SimpleXMLElement Object
								 (
								 )
							 [3] => SimpleXMLElement Object
								 (
								 )
						 )
					 [guid] => http://intelligenttravel.nationalgeographic.com/?p=35345
					 [description] => SimpleXMLElement Object
						 (
						 )
				 )
			 [2] => SimpleXMLElement Object
				 (
					 [title] => Issue Insider: On Newsstands Now
					 [link] => http://intelligenttravel.nationalgeographic.com/2012/10/18/issue-insider-on-newsstands-now/
					 [comments] => http://intelligenttravel.nationalgeographic.com/2012/10/18/issue-insider-on-newsstands-now/#comments
					 [pubDate] => Thu, 18 Oct 2012 18:58:20 +0000
					 [category] => Array
						 (
							 [0] => SimpleXMLElement Object
								 (
								 )
							 [1] => SimpleXMLElement Object
								 (
								 )
							 [2] => SimpleXMLElement Object
								 (
								 )
							 [3] => SimpleXMLElement Object
								 (
								 )

					 [guid] => http://intelligenttravel.nationalgeographic.com/?p=35305
					 [description] => SimpleXMLElement Object
						 (
						 )
				 )

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.