Skip to content

Instantly share code, notes, and snippets.

@ndm2
Created August 9, 2018 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndm2/ba4fdd444eb9753e23e4bbff53eccf88 to your computer and use it in GitHub Desktop.
Save ndm2/ba4fdd444eb9753e23e4bbff53eccf88 to your computer and use it in GitHub Desktop.
Index: src/Utility/Xml.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Utility/Xml.php (date 1533778910000)
+++ src/Utility/Xml.php (date 1533854824127)
@@ -341,7 +341,7 @@
$format = $data['format'];
$node = $data['node'];
- $childNS = $childValue = null;
+ $childNS = $childValue = $isCdata = null;
if (is_object($value) && method_exists($value, 'toArray') && is_callable([$value, 'toArray'])) {
$value = call_user_func([$value, 'toArray']);
}
@@ -350,6 +350,11 @@
$childValue = (string)$value['@'];
unset($value['@']);
}
+ if (isset($value['!'])) {
+ $childValue = (string)$value['!'];
+ $isCdata = true;
+ unset($value['!']);
+ }
if (isset($value['xmlns:'])) {
$childNS = $value['xmlns:'];
unset($value['xmlns:']);
@@ -360,7 +365,11 @@
$child = $dom->createElement($key);
if ($childValue !== null) {
- $child->appendChild($dom->createTextNode($childValue));
+ if (!$isCdata) {
+ $child->appendChild($dom->createTextNode($childValue));
+ } else {
+ $child->appendChild($dom->createCDATASection($childValue));
+ }
}
if ($childNS) {
$child->setAttribute('xmlns', $childNS);
@shadowx-jb
Copy link

Thanks for the explanation, so it's correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment