Public feed #724930

Untitled

public php v1 · immutable
Raw Edit
·published 2007-10-03 23:42 UTC
rendered paste body
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><article articleId="5859" lastModifiedById="13" metatype="Article" rootArticleId="4110" type="India"><title><![CDATA[india]]></title><created>20070516T200000</created><lastmodified>20070606T092337</lastmodified><section type="Paragraph"><title>india</title><asset type="HTML Multiline"><description>Paragraph</description><data><![CDATA[<h1>INDIA</h1><p class="details">First Line<br/>Second Line</p>]]></data></asset></section></article>'; $dom = new DOMDocument('1.0','utf-8'); $dom->loadXML($xml);    $sections = $dom->getElementsByTagName('section');  foreach($sections as $section) {    $xpath = new DomXPath($dom);    $data = $section->getElementsByTagName('data');    $dataElem = $data->item(0);    $d = new DOMDocument();    $d->loadHTML($dataElem->nodeValue);    $xp = new DOMXPath($d);    $xp->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');    $result = $xp->query('//p[@class="details"]');    $resultNode = $result->item(0);    $newDom = new DOMDocument;    $newDom->appendChild($newDom->importNode($resultNode,1));        print $newDom->saveXML();    die(); }?>Returns:<?xml version="1.0"?><p class="details">First Line<br/><img src="hello"/>Second Line</p>