XML dillema
| From: | Teodor Cimpoesu | Date: | Mon, 22 Jan 2001 15:11:13 +0000 |
| Subject: | XML dillema | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-36012@lists.php.net to get a copy of this message | ||
Hey,
I've been playing w/ DOM functions (not very documented, but cool :)
and had the following:
[categories.xml]
<?xml version="1.0"?>
<catalog>
<category id="db" name="Databases">
<topic>
<name>MySQL</name>
<description>MySQL Manual</description>
</topic>
<topic>
<name>PostgreSQL</name>
<description>PostgreSQL Manuals</description>
</topic>
</category>
</catalog>
[xmltest.php]
<?php
header ('Content-Type: text/plain');
$doc = new DomDocument();
$node = new DomNode();
$doc = xmldocfile ('categories.xml');
$root = $doc->root();
$cats = $root->children();
$node = $cats[0];
print_r ($node->name);
It outputs "text" and I would expect "Databases".
running xmllint gives:
[teo@teo xml]$ xmllint --debug categories.xml
DOCUMENT
version=1.0
URL=categories.xml
standalone=true
ELEMENT catalog
TEXT
content=
ELEMENT category
ATTRIBUTE id
TEXT
content=db
ATTRIBUTE name
TEXT
content=Databases
TEXT
[...]
Any idea what's wrong?
TIA
-- teodor