Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Load PRX Document And Display Elements

DZone's Guide to

Load PRX Document And Display Elements

·
Free Resource

//Using a simple curl library (not shown) to get xml text
$curl = new CURL();
//$prx contains the url of a PRX document (e.g. http://www.prxbuilder.com/link.aspx?p=1)
$xml = $curl->get($prx);

//Load the XML file
$doc = new DOMDocument();
$doc->loadXML($xml);

//Retrieve specific PRX elements (subheadline, dateline, body)
$subheadline = $doc->getElementsByTagName('subheadline')->item(0)->nodeValue;
$dateline = $doc->getElementsByTagName('dateline')->item(0)->nodeValue;
$body = $doc->getElementsByTagName('body')->item(0)->nodeValue;

//Format and display - apply_filters is a WP function.
$content = '

'.$subheadline.'

'; $content .= '

'.$dateline.'

'; $content .= '

'.$body.'

'; $content = apply_filters('the_content_rss', $content); $content = str_replace(']]>', ']]>', $content); echo $content;
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}