simplxml questions

[email protected] (Tobias Bradtke) Fri, 26 Dec 2003 05:13:50 +0100
Newsgroups php.xml.dev
Message-ID <[email protected]>
hi!

i can't figure out how to access node-values wihtin simplexml..


example-code --

$sxe = simplexml_load_string("
	<doc>
		<product id='97'>
			<number>art123</number>
			<info lang='en'>long text</info>
			<price from='1'>1</price>
			<price from='5'>0.95</price>
		</product>
		<product id='98'>
			<number>art123</number>
			<info lang='en'>long text</info>
			<info lang='de'>langer text</info>
			<price from='1'>2</price>
			<price from='5'>1.95</price>
		</product>
		<product id='99'>
			<number>art123</number>
			<info>long text</info>
			<info>langer text</info>
			<price from='1'>3</price>
			<price from='5'>2.95</price>
		</product>
	</doc>
	");

$sxe->product[0]->info = 'an other text'; // works
$sxe->product[1]->info[0] = 'an other text'; // does not work
$sxe->product[2]->info[0] = 'an other text'; // does not work

echo ('<pre>'); print_r($sxe); echo ('</pre>');

echo '<pre>'.htmlentities($sxe->to_xml_string()).'</pre>';

end --


in the first product i can change the info-text.
the second and third do nothing..

with
$sxe->product[1]->info['lang'] = 'fr';
i can change the attribute, maybe this is conflicting with accessing the
   array of the info-nodes, but in the third case, where there is no
attribute i can't access the values neither.

is the anoter-method like
$sxe->product[1]->info[0]->content = 'fr';
or something?


i wasn't able to find much info about simplexml od the web; primarily
very short examples..

is there anywhere a more in-depth documentation?


merry christmas!
tobias