2003-12-17 22:49:10 +08:00
|
|
|
--TEST--
|
|
|
|
SimpleXML: modifying attributes of singular subnode
|
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
$xml =<<<EOF
|
|
|
|
<people>
|
|
|
|
<person name="Joe"></person>
|
|
|
|
</people>
|
|
|
|
EOF;
|
|
|
|
|
|
|
|
$people = simplexml_load_string($xml);
|
|
|
|
var_dump($people->person['name']);
|
2003-12-18 21:35:39 +08:00
|
|
|
$people->person['name'] = $people->person['name'] . 'Foo';
|
|
|
|
var_dump($people->person['name']);
|
|
|
|
$people->person['name'] .= 'Bar';
|
2003-12-17 22:49:10 +08:00
|
|
|
var_dump($people->person['name']);
|
2003-12-18 21:35:39 +08:00
|
|
|
|
|
|
|
echo "---[0]---\n";
|
|
|
|
|
|
|
|
$people = simplexml_load_string($xml);
|
|
|
|
var_dump($people->person[0]['name']);
|
|
|
|
$people->person[0]['name'] = $people->person[0]['name'] . 'Foo';
|
2003-12-17 22:49:10 +08:00
|
|
|
var_dump($people->person[0]['name']);
|
2003-12-18 21:35:39 +08:00
|
|
|
$people->person[0]['name'] .= 'Bar';
|
|
|
|
var_dump($people->person[0]['name']);
|
|
|
|
|
2003-12-17 22:49:10 +08:00
|
|
|
?>
|
2004-01-18 03:41:32 +08:00
|
|
|
===DONE===
|
2003-12-17 22:49:10 +08:00
|
|
|
--EXPECT--
|
2004-01-18 03:41:32 +08:00
|
|
|
object(simplexml_element)#4 (1) {
|
|
|
|
[0]=>
|
|
|
|
string(3) "Joe"
|
|
|
|
}
|
|
|
|
object(simplexml_element)#2 (1) {
|
|
|
|
[0]=>
|
|
|
|
string(6) "JoeFoo"
|
|
|
|
}
|
|
|
|
object(simplexml_element)#5 (1) {
|
|
|
|
[0]=>
|
|
|
|
string(9) "JoeFooBar"
|
|
|
|
}
|
2003-12-18 21:35:39 +08:00
|
|
|
---[0]---
|
2004-01-18 03:41:32 +08:00
|
|
|
object(simplexml_element)#3 (1) {
|
|
|
|
[0]=>
|
|
|
|
string(3) "Joe"
|
|
|
|
}
|
|
|
|
object(simplexml_element)#2 (1) {
|
|
|
|
[0]=>
|
|
|
|
string(6) "JoeFoo"
|
|
|
|
}
|
|
|
|
object(simplexml_element)#5 (1) {
|
|
|
|
[0]=>
|
|
|
|
string(9) "JoeFooBar"
|
|
|
|
}
|
|
|
|
===Done===
|