xref: /PHP-5.4/ext/simplexml/tests/016.phpt (revision b6321d4e)
1--TEST--
2SimpleXML: modifying attributes of singular subnode
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7$xml =<<<EOF
8<people>
9   <person name="Joe"></person>
10</people>
11EOF;
12
13$people = simplexml_load_string($xml);
14var_dump($people->person['name']);
15$people->person['name'] = $people->person['name'] . 'Foo';
16var_dump($people->person['name']);
17$people->person['name'] .= 'Bar';
18var_dump($people->person['name']);
19
20echo "---[0]---\n";
21
22$people = simplexml_load_string($xml);
23var_dump($people->person[0]['name']);
24$people->person[0]['name'] = $people->person[0]['name'] . 'Foo';
25var_dump($people->person[0]['name']);
26$people->person[0]['name'] .= 'Bar';
27var_dump($people->person[0]['name']);
28
29?>
30===DONE===
31--EXPECTF--
32object(SimpleXMLElement)#%d (1) {
33  [0]=>
34  string(3) "Joe"
35}
36object(SimpleXMLElement)#%d (1) {
37  [0]=>
38  string(6) "JoeFoo"
39}
40object(SimpleXMLElement)#%d (1) {
41  [0]=>
42  string(9) "JoeFooBar"
43}
44---[0]---
45object(SimpleXMLElement)#%d (1) {
46  [0]=>
47  string(3) "Joe"
48}
49object(SimpleXMLElement)#%d (1) {
50  [0]=>
51  string(6) "JoeFoo"
52}
53object(SimpleXMLElement)#%d (1) {
54  [0]=>
55  string(9) "JoeFooBar"
56}
57===DONE===
58