Hi Joseph.
Sorry it took so long to reply, I moved house this last month, my PDA died,
my desktop died, and my hard drive was dying, so I'm still finding my
feet...
Sorry, no there is no easy way to do this. The exportAsXml() wants a node,
and returns both start and end tags. A regular expression should do the
trick though, something like:
$XmlResult2 = preg_replace("/^[^>]*>(.*)<[^<]*$/", "\\1", $XmlResult);
Cheers
Nigel
==========================================
See full example below:
<?
require_once '../XPath.class.php';
$xPath = new XPath();
$rootPath = $xPath->importFromFile('Junk.xml');
// Output what we start with.
echo "<pre>";
echo htmlspecialchars($xPath->exportAsXml());
echo "</pre>";
echo "<hr>";
// Seems to find only one node.
$aResults = $xPath->match("//content_dictionary/content_item");
print_r($aResults);
echo "<hr>";
// Seems to find only one node.
$XmlResult = $xPath->exportAsXml($aResults[0]);
print_r(htmlspecialchars($XmlResult));
echo "<hr>";
$XmlResult2 = preg_replace("/^[^>]*>(.*)<[^<]*$/", "\\1", $XmlResult);
print_r(htmlspecialchars($XmlResult2));
echo "<hr>";
// And output just for clarity
echo "<pre>";
echo htmlspecialchars($xPath->exportAsXml());
echo "</pre>";
?>
|