Hello Stanislav, Monday, December 1, 2003, 5:51:20 PM, you wrote:
> AMT>> Are we discussing this feature's technical or aesthetic merits? Or > AMT>> both? > Technical. > AMT>> foreach ($dom->getElementsByTagname('person') as $person) { > AMT>> list($firstname) = > $person->getElementsByTagname('firstname'); > AMT>> $firstname_text_value = $firstname->firstChild->nodeValue; > AMT>> } > AMT>> > AMT>> Compare that to: > AMT>> > AMT>> foreach($s->person as $person) { > AMT>> $firstname_text_value = $person->firstname; > AMT>> } > AMT>> > AMT>> You tell me which one "nobody can understand." > Both can be understood, but in the first case you know wat is going on (so > you can rely on $s->person being array and you would be able to do: > $elements = $dom->getElementsByTagname('person'); > do_something_with($elements[0]); > and in the second case there's so much magic you don't know what the hell > is really going on. That's OK when you need to do just that, that stops to > be OK when you want to slightly modify the behaviour and discover the > magic is tightly coupled with particular case of use. For example, what > exactly is $person->firstname there? Tag, or some attribute, or contents? > What is $s->person - is it list of all tags with name 'person' contained > in $s or is it element with ID 'person' in $s or maybe it is 'person' > attribute of tag $s? How can I see it from that code? I can't. print($xml->iWant->ToHave->TheFirstName->OfThisPerson()); Yeah that looks pretty stupid... print($xml->Person->element["Name"]->Attributes["First"]); or was it print($xml->Person->element["Name"]->First->__toString); i don't know! Thats's the place SimpleXML was designed for. To allow you to write easy code that does the object binding automatically: print($xml->Person->Name->First); -- Best regards, Marcus mailto:[EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php