user1876553
user1876553

Reputation: 113

How to Parse XML from a URL using PHP

Im learning how to parse XML elements into an html document.

This takes a url with an xml, reads the elements but it ain't working...also I want to take it a bit further but I simply haven't been able to, how can I make it so I read the xml from a url? and use an xml element as filename to create an html document using a template?

////EDIT this is what I tried! /////EDIT/////EDIT/////EDIT/////EDIT/////EDIT/////EDIT

I tried this just for the sake of me knowing what Im doing(...apparently nothing haha) so I could echo if the information was right....

<?php

 $url = "http://your_blog.blogspot.com/feeds/posts/default?alt=rss";
 $xml = simplexml_load_file($url);
 print_r($xml);

?> 

Thank you for your time!

Upvotes: 1

Views: 128

Answers (1)

bitoffdev
bitoffdev

Reputation: 3384

Generally, "cross-domain" requests would be forbidden by web browsers, per the same origin security policy.

However, there is a mechanism that allows JavaScript on a web page to make XMLHttpRequests to another domain called Cross-origin resource sharing (CORS).

Read this about CORS: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

Check this article out about RSS feeds: http://www.w3schools.com/php/php_ajax_rss_reader.asp

Upvotes: 1

Related Questions