Php reading rss (2)

Source: Internet
Author: User
Metacontenttexthtml; charsetutf-8http-equivContent-Type? PhpThefiletest. xmlcontainsanXMLdocumentwitharootelementandatleastanelement [root] title. $ xmlfiledate (YmdH).. xml; $ sourcexmlmedcl. n

Meta content = "text/html; charset = UTF-8" http-equiv = "Content-Type "? Php // The file test. xml contains an XML document with a root element // and at least an element/[root]/title. $ xmlfile = date ('ymmdh '). '. xml'; $ sourcexml = 'HTTP: // medcl. n

// The file test. xml contains an XML document with a root element

// And at least an element/[root]/title.

$ Xmlfile = date ('ymmdh'). '. xml ';

$ Sourcexml = 'HTTP: // medcl.net/SinaRss.aspx? Uid = 1562882353 ';

// Die ($ xmlfile );

If (! File_exists ($ xmlfile )){

Echo 'the first time you visited the system. Initializing ...';

$ Str = @ file ($ sourcexml) or die ('An error occurred while loading the file. ');

$ Str = join ('', $ str );

$ Fp = fopen ($ xmlfile, 'w') or die ('write cache failed! ');

Fputs ($ fp, $ str );

Fclose ($ fp );

Echo "Initialization is complete. ";

}

If (file_exists ($ xmlfile )){

$ Xml = simplexml_load_file ($ xmlfile );

// Print_r ($ xml );

$ C = & $ xml-> channel;

Echo'

Link. '">'. $ c-> title .'

';

Echo'

'. $ C-> lastBuildDate .'

';

$ Listhead ='

';

Echo $ listhead;

$ K = 0;

Foreach ($ c-> item as $ v ){

$ K ++;

Echo"

";

}

Echo'

Serial number Title Author Category Comment Time
$ K Title. "href =". $ v-> link. "> $ v-> title $ V-> author $ V-> category Comments. "> comment $ V-> pubDate

';

} Else {

Exit ('failed to open xml file .');

}

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.