Re: [PHP4BETA] cvs: /php4/ext/pdf pdf.c
| From: | Uwe Steinmann | Date: | Fri, 10 Mar 2000 11:14:28 +0000 |
| Subject: | Re: [PHP4BETA] cvs: /php4/ext/pdf pdf.c | ||
| References: | 1 2 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11859@lists.php.net to get a copy of this message | ||
On Fri, Mar 10, 2000 at 10:10:31AM +0100, Kristian Koehntopp wrote:
>
> How am I using the domxml extension?
>
> I have used
>
> $o = xmldocfile("skdtest");
>
> to read and parse an XML file and I can dump
> the document structure using a recursive function
> dump():
>
> function dump(&$o, $level = 0) {
> dent($level);
> printf("%s is a %s of type %s\n",
> $o->name,
> get_class($o),
> $xml_type[$o->type]);
>
> $c = $o->children();
> if (is_array($c)) {
> reset($c);
> while(list($k, $v) = each($c)) {
> dump($v, $level+2);
> }
> }
>
> Within my XML document there are containers named QUESTION and
> ANSWER. I do not want to decend into these containers, but dump
> domxml_dumpmem() them. But
>
> if ($o->name != "QUESTION" and $o->name != "ANSWERS") {
> $c = o->children();
> ...
> } else {
> print htmlspecialchars($o->dumpmem());
> }
>
> does not work, because I need a Dom Document object, not a Dom
> Node object to dump this. So how would I create a new Dom
> Document named $p and add the $o subtree to $p easily?
>
> From the source I gather that it cannot be done, because the
> DomXML extension keeps the XML tree in libXML structure and does
> not create true PHP objects to represent the XML tree instead.
> That is, I cannot $p->children[] = $o;
My intention is to make exactly this possible and xmltree() is the
begining. It returns a complete tree made of php objects.
The drawback right now, you cannot dump it, unless you do it in
PHP yourself. Another drawback, you cannot create new nodes and
add it.
The second solution is to use domxml_new_child() which adds a child
to the internal libxml tree. But this function isn't very well tested.
>
> But also there is no function $p->addnode($o); with will add
> $o and the whole subtree below $o to $p.
domxml_new_child() just adds one child not a tree.
> Finally: Is it intentional that the DomXML classnames are
> illegal classnames containing spaces?
No, just my stupidity. I'll fix it.
Uwe
--
Uwe.Steinmann@fernuni-hagen.de
Tel: +2331 987 4528 Fax: +2331 987 375