I can't answer on your first topic, but the second:
On 22.5.2007 10:23 Uhr, Vesselin Kenashkov wrote: > Hello everybody, > Issue #2: > Xpath on nodes. > Let we have the example: > ----------------- > $str = > '<rootnode><level1_node1><level2_node1></level2_node1></level1_node1><level1_node2></level1_node2></rootnode>'; > > > $x = new SimpleXMLElement($str); > > $r1 = $x->xpath('/*'); > print $r1[0]->getName();//prints rootnode > > $r2 = $x->level1_node1[0]->xpath('/*'); > print $r2[0]->getName();//prints rootnode > > $z = clone $x->level1_node1[0]; > $r3 = $z->xpath('/*'); > print $r3[0]->getName();//prints rootnode > > //print $z->getName();//ok > ------------------ That's how it works also in ext/dom (and IMHO as it's supposed to work), but the "workaround" is easy: $r2 = $z->xpath('./*'); works as you would expect it. chregu > I personally think that the xpath must be evaluated against the node which > method is called, not always against the rootnode. > So in the second example I would expect it to return level1_node1, and > especially in the thirds example. > Even in the third example the xpath is evaluated against the original XML > structure, not the subnode (level1_node1). > I think this is incorrect and leads to a confusion - for example we can > pass > a node to a function like: > -------- > function do_something($node) > { > //print $node->getName();//prints correct - the name of the supplied > node - level1_node1 > $r1 = $node->xpath('/*'); > print $r1[0]->getName(); > } > > do_something(clone $x->level1_node1[0]); > -------- > The do_something function is not aware at all about the full xml structure > and one could think that the expression will be evaluated just against the > supplied node, but it is not that the case. > > Please give your comments - do you find this functionality OK, is it a bug, > or I miss something. > > > Vesselin Kenashkov > -- christian stocker | Liip AG | schoeneggstrasse 5 | ch-8004 zurich phone +41 44 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.liip.ch/ | [EMAIL PROTECTED] | GnuPG 0x5CE1DECB -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php