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===
|
2004-01-23 05:47:54 +08:00
|
|
|
--EXPECTF--
|
2004-03-30 03:58:01 +08:00
|
|
|
object(SimpleXMLElement)#%d (1) {
|
2004-01-18 03:41:32 +08:00
|
|
|
[0]=>
|
|
|
|
string(3) "Joe"
|
|
|
|
}
|
2004-03-30 03:58:01 +08:00
|
|
|
object(SimpleXMLElement)#%d (1) {
|
2004-01-18 03:41:32 +08:00
|
|
|
[0]=>
|
|
|
|
string(6) "JoeFoo"
|
|
|
|
}
|
2004-03-30 03:58:01 +08:00
|
|
|
object(SimpleXMLElement)#%d (1) {
|
2004-01-18 03:41:32 +08:00
|
|
|
[0]=>
|
|
|
|
string(9) "JoeFooBar"
|
|
|
|
}
|
2003-12-18 21:35:39 +08:00
|
|
|
---[0]---
|
2004-03-30 03:58:01 +08:00
|
|
|
object(SimpleXMLElement)#%d (1) {
|
2004-01-18 03:41:32 +08:00
|
|
|
[0]=>
|
|
|
|
string(3) "Joe"
|
|
|
|
}
|
2004-03-30 03:58:01 +08:00
|
|
|
object(SimpleXMLElement)#%d (1) {
|
2004-01-18 03:41:32 +08:00
|
|
|
[0]=>
|
|
|
|
string(6) "JoeFoo"
|
|
|
|
}
|
2004-03-30 03:58:01 +08:00
|
|
|
object(SimpleXMLElement)#%d (1) {
|
2004-01-18 03:41:32 +08:00
|
|
|
[0]=>
|
|
|
|
string(9) "JoeFooBar"
|
|
|
|
}
|
2004-02-11 20:19:26 +08:00
|
|
|
===DONE===
|