Rev 5 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 12 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * PHP SimpleXML-Supplement |
4 | * PHP SimpleXML-Supplement |
5 | * Copyright 2020 - 2021 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2020 - 2021 Daniel Marschall, ViaThinkSoft |
6 | * Revision 2021-05-25 |
6 | * Revision 2021-06-12 |
7 | * |
7 | * |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | * you may not use this file except in compliance with the License. |
9 | * you may not use this file except in compliance with the License. |
10 | * You may obtain a copy of the License at |
10 | * You may obtain a copy of the License at |
11 | * |
11 | * |
Line 88... | Line 88... | ||
88 | foreach ($m as $n) { |
88 | foreach ($m as $n) { |
89 | $name = $n[1]; |
89 | $name = $n[1]; |
90 | $other = $n[2]; |
90 | $other = $n[2]; |
91 | $val = $n[3]; |
91 | $val = $n[3]; |
92 | 92 | ||
- | 93 | // We are using chr(1) to avoid that <x> is parsed as child if it follows CDATA immediately |
|
93 | $val = str_replace('<![CDATA[', '', $val); |
94 | $val = str_replace('<![CDATA[', chr(1), $val); |
94 | $val = str_replace(']]>', '', $val); |
95 | $val = str_replace(']]>', chr(1), $val); |
95 | $val = trim($val); |
96 | $val = trim($val); |
96 | 97 | ||
97 | $new = $out->addChild($name, $val); |
98 | $new = $out->addChild($name, $val); |
98 | 99 | ||
99 | $m2 = array(); |
100 | $m2 = array(); |
Line 216... | Line 217... | ||
216 | 217 | ||
217 | if ((substr(trim($val),0,1) === '<') || (trim($val) == '')) { |
218 | if ((substr(trim($val),0,1) === '<') || (trim($val) == '')) { |
218 | $val = simplexml_load_string($val); |
219 | $val = simplexml_load_string($val); |
219 | } |
220 | } |
220 | 221 | ||
- | 222 | if (is_string($val)) $val = str_replace(chr(1), '', $val); |
|
- | 223 | ||
221 | $data = get_object_vars($this); |
224 | $data = get_object_vars($this); |
222 | 225 | ||
223 | if (!isset($data[$name])) { |
226 | if (!isset($data[$name])) { |
224 | if ($val instanceof SimpleXMLElement) { |
227 | if ($val instanceof SimpleXMLElement) { |
225 | $this->$name = $val; |
228 | $this->$name = $val; |