You are here: Re: simplexml with xpath, getting index of results « PHP Programming Language « IT news, forums, messages
Re: simplexml with xpath, getting index of results

Posted by sugoi.sama on 01/02/06 14:26

That doesn't solve my problem.
I guess i didn't explain myself very well...

------------------------ MY XML FILE:
.....
xmlns:lib="http://en.wikipedia.org/wiki/Manga"
.....
<lib:manga title="Fullmetal">
<numVolumes>14</numVolumes>
</lib:manga>
.....
-------------------------


by doing this:
++++++++++++++++++++++++++++++
$mangaLib = simplexml_load_file($mangaLibFile);
$mangaObj = $mangaLib->children($mangaURI);
$tmp = $mangaObj->xpath('//numVolumes[../@title="'.$title.'"]');
var_dump($tmp);
++++++++++++++++++++++++++++++

i get:
---++++++++++---
array(1) {
[0]=>
object(SimpleXMLElement)#18 (1) {
[0]=>
string(2) "14" // <numVolumes>14</numVolumes>
}
}
---++++++++++---




What i want to do is, change <numVolumes> from 14, to some other value!
So i would do this:

$mangaObj->manga[$INDEX]->numVolumes = 12345;

But to accomplish that, i need to know the value of $INDEX, am i
correct or is there other way?
Because i simply can't do anything with $tmp!!! I can't access it and
change it's value! (and i'm assuming it's a reference)

I can't do this: $tmp[0]->object[0] = 12345;
(this doesn't even make sense)

How can i change <numVolumes> value?

thanks in advance

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация