#42039 [Opn->Bgs]: item function read xml

From: Date: Thu, 19 Jul 2007 06:06:57 +0000
Subject: #42039 [Opn->Bgs]: item function read xml
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115216@lists.php.net to get a copy of this message
 ID:               42039
 Updated by:       chregu@php.net
 Reported By:      ichigoxi at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *XML functions
 Operating System: ubuntu/linux
 PHP Version:      5.2.3
 New Comment:

Please read how DOM works. There are Textnodes between your Elements, 
which also count as items, so ->item(1) would be the a element in your

example and item(3) the b element.

I'd advise you to use xpath for much more accurate pinpointing of 
nodes...


Previous Comments:
------------------------------------------------------------------------

[2007-07-19 03:04:51] ichigoxi at gmail dot com

Description:
------------
like this xml------->
<root>
<item>
<a>11</a>
<b>1</b>
<c>0</c>
</item>
</root>

$dom = new DOMDocument();
$dom->load('test.xml');
$root = $dom->documentElement;
$items = $root->childNodes;
$item = $items->item(0);
$itemChildren = $item->childNodes;
$b = $itemChildren->item(1);
echo $b->nodeValue;

this code can not read $b from the xml
but this xml---------->
<root><item><a>11</a><b>1</b><c>0</c></item></root>

the code can read $b 





------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42039&edit=1


Thread (3 messages)

« previous php.bugs (#115216) next »