|
Posted by sugoi.sama on 01/02/06 12:31
hi,
i'm having a hellish adventure with PHP5 i hope someone just can help
me out on this... i'm desperate
All i want to do, is to get the index of the returned elements, so i
can acess them and change them
(i'm guessing this is the only way to do this, as i can't change the
element on-the-fly in XPath )
$mangaLib = simplexml_load_file($mangaLibFile);
$mangaObj = $mangaLib->children($mangaURI);
$tmp = $mangaObj->xpath('//id[../@title="'.$title.'"][position()]');
// (1)
..... do magic here, to get $ind...
$mangaObj->manga[$ind]->volumes = 666; // (2)
(1) var_dump($tmp) returns:
array(1) {
[0]=>
object(SimpleXMLElement)#18 (1) {
[0]=>
string(3) "100" // value of id (which i don't care)
}
}
(2) this is my objective, get the $index and use it
elements "volumes" and "id" are on the same level
i really don't care about the "id" node value, what i want is its
position, but PHP complained if i used it without id:
$tmp = $mangaObj->xpath('//[../@title="'.$title.'"][position()]');
isn't position() supposed to return the index i want?!
OR.... is this impossible to accomplish PHP and XPath....
if so, can i use any of DOM, SAX, XMLReader to accomplish my task?
(although i would like to do this with all methods)
thansk for any help
[Back to original message]
|