New to XML and I need some help with a very basic problem. I can use xslt and I can use domxpath, but I can't get them working together.
I want to be able to echo my XML styled with XSL, delimited by an xpath.
This code echos my styled XML perfectly:
$xp = new XsltProcessor();
$xsl = new DomDocument;
$xsl->load('style3.xsl');
$xp->importStylesheet($xsl);
$xml_doc = new DomDocument;
$xml_doc->load('books.xml');
if ($html = $xp->transformToXML($xml_doc)) {
echo $html;
} else {
trigger_error('XSL transformation failed.', E_USER_ERROR);
} // if
?>
This code prints the delimitation I want, but is not styled:
$dom = new DomDocument();
$dom->load("books.xml");
$xp = new domxpath($dom);
$titles = $xp->query("/book_catalog/book[genre = 'Fiction']");
foreach ($titles as $node) {
print $node->textContent . "<br><br>";
};
I've tried everything I can think of to integrate some form of the two, but without success. HELP?