Re: Is really no one interested?
| From: | Christian Stocker | Date: | Tue, 01 Nov 2005 07:51:07 +0000 |
| Subject: | Re: Is really no one interested? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19872@lists.php.net to get a copy of this message | ||
On 1.11.2005 8:48 Uhr, Marian Kostadinov wrote:
> Who says that I have a well-formed DTD? DTD is not necessary in many
> cases. I will illustrate with example why DOM is too "complex" ...
> compared to SimpleXML.
>
> <?php
> //These are my 2 XML documents. No DTD - just a simple xml structure.
> $xml1 =
> '<root1><q/><a><b><c><d>hi1</d></c></b></a><q/></root1>';
> $xml2 =
> '<root2><q/><a><b><c><d>hi2</d></c></b></a><q/></root2>';
>
> $sxe1 = new SimpleXMLElement ($xml1);
> $sxe2 = new SimpleXMLElement ($xml2);
>
> //Easy access to a node. It's great!
> echo $sxe1->a->b->c->d;
> echo $sxe2->a->b->c->d;
>
> //But how can I understand what is the name of the root node?
> $dom_sxe = dom_import_simplexml($sxe1);
>
> //Hooray, we've got node name
> echo $dom_sxe->nodeName;
>
> //And what happens if element sequence changes? .
> echo
> $dom_sxe->childNodes->item(1)->firstChild->firstChild->firstChild->nodeValue;
> //... hm... I prefer SimpleXML.
use xpath :) as easy as simplexml and much more powerfull, IMHO
and noone said you should use exclusively dom.
chregu
--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71
http://www.bitflux.ch | christian.stocker@bitflux.ch | GPG
0x5CE1DECB