Re: [PHP-XML-DEV] getElementById question (bug report)

[email protected] (Christian Stocker) Wed, 26 May 2004 09:53:11 +0200
Newsgroups php.xml.dev
Message-ID <[email protected]>

On 26.5.2004 9:52 Uhr, Bernhard Zwischenbrugger wrote:

> Hi
> 
> I have a problem with "getElementById":
> 
> Working example:
> ============
> -----------snip---
>  <?php
> $xmlstring = '<?xml version="1.0" ?>
> <!DOCTYPE books [
> <!ATTLIST book id ID #IMPLIED>
> ]>
> <books>
>     <book id="1">
>         <title>Book 1</title>
>     </book>
>     <book id="2">
>         <title>Book 2</title>
>     </book>
> </books>';
> 
> $dom = new DomDocument();
> $dom->loadXML($xmlstring);
> $node = $dom->getElementById("1");
> print $node->nodeValue;
> ?>
> ----snap--------
> 
> NOT working example:
> ===============
> 
> ---snip---
>  <?php
> $xmlstring = '<?xml version="1.0" ?>
> <books>
>     <book id="1">
>         <title>Book 1</title>
>     </book>
>     <book id="2">
>         <title>Book 2</title>
>     </book>
> </books>';
> 
> $dom = new DomDocument();
> $dom->loadXML($xmlstring);
> $node = $dom->getElementById("1");
> print $node->nodeValue;
> ?>
> ----snap-----
> 
> ===========
> 
> If there is no DTD the method "getElementById" is not working.
> I don't know the DOM Standard very good, but I think this is an PHP error.

No, this is the correct behaviour.

chregu


> 
> Env:
> PHP5 RC2, Linux 
> 
> Bernhard
> 

-- 
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  |  [email protected]  |  gnupg-keyid 0x5CE1DECB