Could you help me clarify one thing that I don't understand... let's put it simple, just imagine that I have a tiny XML document with a list of movies:

<movies>
        <title>
                <i>Gone</i> with <b>the</b> wind
        </title>
</movies>

I want to read this XML file and write the name of the first (and only) movie in the list; for this reason I have choose to use SimpleXML since it was looking quite user-friendly.

But there's a thing I don't understand... when I have some children, how do I understand which is the first child and which is the last ? I have tried to write this, but I'm getting a wrong result: instead of "Gone with the wind" I got "with wind Gone the", because I understand that the tag <title> contains all the text that is not formatted, and then it writes all the children of <title>: <i>Gone</i> and <b>the</b>

<?php

$xml = new SimpleXMLElement("<movies><title><i>Gone</i> with <b>the</ b> wind</title></movies>");
        
        echo ($xml->title . " ");
        foreach ($xml->title->children() as $element) {
                echo ($element . " ");
        }
        
        // Returns "with wind Gone the"
        
?>

I'm using PHP 5.2.5, could you tell me what am I doing wrong ? Thank you

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to