I am trying to read an xml file and output part of it in html. I have an xml file with sections[1...20] and an xsl file that adds html tags to it. What I am trying to do with php is to have a parser that will read the xml file and output just one required section.
I tried a few ways of doing this and figured out that everything described in the php man is pretty complicated and the examples I found on Goggle are not talking about what I want.
Is there a way/lib that will allow me get a node, print it's attributes and incupsulated text?
I wrote this code to get attributes of nodes (it only works with flat xml file so far).
<?
//$doc = xmldocfile("c:/www/box/content.xml");
//when I try xmldocfile funtion and new nodes are placed on new
//lines, then I get extra empty objects added to it.
//I had to remove all \n and \r from the file to get rid of it.
$docstr = join("",file("content.xml","r"));
$docfin = ereg_replace("\n|\r","",$docstr);
$doc = xmldoc($docfin);
$root = $doc->root();
foreach(domxml_children($root) as $ch)
{
$level = domxml_getattr($ch,"level");
$name = domxml_getattr($ch,"name");
$parent = domxml_getattr($ch,"parent");
echo "$level, $name, $parent";
}
domxml_dumpmem($doc);
?>
however, I don't know how to read the text inside the node and many other things are quite complicated still. Is there a handy lib I can use?