ID: 14500
Updated by: mfischer
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: DOM XML related
Operating System: Slackware 8.0
PHP Version: 4.1.0
New Comment:

Documentation has not been updates because domxml is still experimental. Domxml now 
(or, it should) conform to the DOM2 API.

Try going for the children() nodes of the 'name' element.

Btw, my output with 4.1.0 looks like:

DomDocument Object
(
    [name] => 
    [url] => 
    [version] => 1.0
    [standalone] => -1
    [type] => 9
    [compression] => -1
    [charset] => 1
    [0] => 1
    [1] => 136076352
    [children] => Array
        (
            [0] => DomElement Object
                (
                    [type] => 1
                    [tagname] => me
                    [0] => 2
                    [1] => 136076472
                    [children] => Array
                        (
                            [0] => DomElement Object
                                (
                                    [type] => 1
                                    [tagname] => name
                                    [0] => 3
                                    [1] => 136076560
                                    [children] => Array
                                        (
                                            [0] => DomText Object
                                                (
                                                    [type] => 3
                                                    [content] => JoeCool
                                                    [0] => 4
                                                    [1] => 136076632
                                                )

                                        )

                                )

                            [1] => DomElement Object
                                (
                                    [type] => 1
                                    [tagname] => age
                                    [0] => 5
                                    [1] => 136076704
                                    [children] => Array
                                        (
                                            [0] => DomText Object
                                                (
                                                    [type] => 3
                                                    [content] => 24
                                                    [0] => 6
                                                    [1] => 136076776
                                                )

                                        )

                                )

                            [2] => DomElement Object
                                (
                                    [type] => 1
                                    [tagname] => sex
                                    [0] => 7
                                    [1] => 136076848
                                    [children] => Array
                                        (
                                            [0] => DomText Object
                                                (
                                                    [type] => 3
                                                    [content] => male
                                                    [0] => 8
                                                    [1] => 136076920
                                                )

                                        )

                                )

                        )

                )

        )

)

You were obviously missing some important information.

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

[2001-12-14 03:44:10] [EMAIL PROTECTED]

Thanks, but that doesn't solve my problem yet.
I used print_r($root)and indeed I can see that property changed name to "tagname". But 
thereis is no property "content".I use this xml document:

<?xml version=\"1.\">
<me><name>JoeCool</name><age>24</age><sex>male</sex></me>

And then I do
 $docTree = xmltree($myXML); (where $myXML contains the xml)
 print_r( $docTree );
 
What I get is: 

Array
(
    [0] => DomElement Object
        (
            [type] => 1
            [tagname] => name
            [0] => 3
            [1] => 137743960
        )

    [1] => DomElement Object
        (
            [type] => 1
            [tagname] => age
            [0] => 4
            [1] => 137744104
        )

    [2] => DomElement Object
        (
            [type] => 1
            [tagname] => sex
            [0] => 5
            [1] => 137744248
        )

But there is no property "content" like in older versions of libxml. How can I get the 
value of name, age and sex ?I 've 
searched the site php.net and there is no informations about any changes in libxml 
interface.

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

[2001-12-13 23:04:06] [EMAIL PROTECTED]

The interface has changed, the property is now named 'tagname'.

print_r($root) is your friend if you can't find what you're searching for (and the 
source of course).

Closing.

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

[2001-12-13 18:55:11] [EMAIL PROTECTED]

I've compiled PHP-4.1.0 with libxml2-2.4.2 on linux machine
with that options:
/configure --with-apache=../apache_1.3.22 --enable-trans-sid --with-mysql=/mysql 
--disable-magic-quotes --with-dom --with-qtdom --with-zlib --with-png 
--with-ttf --enable-safe-mode --enable-track-vars --with-xml

When I trie to use any domxml functions (below a part of php code taken from manual) I 
get error in my php_error_log 
like this:

"Undefined property:  name in example.php"
"Undefined property:  name in example.php"

// data file
$str = "<?xml version=\"1.0\"?><me><name>Joe
Cool</name><age>24</age><sex>male</sex></me>";
// create a document object
$dom = xmldoc($str);

// get reference to root node
$root = $dom->root();

// get name of node - "me"
echo $root->name;

// get children of node, as array
$children = $root->children();

I checked the same script with older version of php (4.0.6)and libxml2 (2.2.3) and it 
works.
Any ideas what I do wrong?

Agnieszka Kukalowicz 



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



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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to