1

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!

4

1 回答 1

1

通常,根据同源安全策略,Web 浏览器会禁止“跨域”请求。

但是,有一种机制允许网页上的 JavaScript 向另一个域发出 XMLHttpRequest,称为跨域资源共享 (CORS)。

阅读有关 CORS 的信息: http ://en.wikipedia.org/wiki/Cross-origin_resource_sharing

查看这篇关于 RSS 源的文章:http: //www.w3schools.com/php/php_ajax_rss_reader.asp

于 2013-10-24T16:51:24.283 回答