File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
class SimpleXMLElement extends \SimpleXMLElement
6
6
{
7
+ public function addChild ($ name , $ value = null , $ namespace = null )
8
+ {
9
+ if ( $ value !== null and is_string ($ value ) === true )
10
+ {
11
+ $ value = str_replace ('& ' , '& ' , $ value );
12
+ }
13
+
14
+ return parent ::addChild ($ name , $ value , $ namespace );
15
+ }
7
16
}
Original file line number Diff line number Diff line change @@ -155,4 +155,18 @@ public function testAsXML_test_Japanese()
155
155
156
156
$ this ->assertXmlStringEqualsXmlString ($ expect , $ item ->asXML ()->asXML ());
157
157
}
158
+
159
+ public function test_with_amp ()
160
+ {
161
+ $ item = new Item ();
162
+ $ item
163
+ ->title ('test&test ' )
164
+ ->url ('url&url ' )
165
+ ->description ('desc&desc ' );
166
+ $ expect = '<?xml version="1.0" encoding="UTF-8"?>
167
+ <item><title>test&test</title><link>url&url</link><description>desc&desc</description></item>
168
+ ' ;
169
+
170
+ $ this ->assertSame ($ expect , $ item ->asXML ()->asXML ());
171
+ }
158
172
}
You can’t perform that action at this time.
0 commit comments