$this->
buildXml($root,
$data,
$format,
$context,
$xmlRootNodeName);
} else { $this->
appendNode($dom,
$data,
$format,
$context,
$xmlRootNodeName);
} return $dom->
saveXML($ignorePiNode ?
$dom->documentElement : null,
$context[self::SAVE_OPTIONS
] ??
$this->defaultContext
[self::SAVE_OPTIONS
]);
} public function decode(string
$data, string
$format, array
$context =
[]): mixed
{ if ('' ===
trim($data)) { throw new NotEncodableValueException('Invalid XML data, it cannot be empty.'
);
} $internalErrors =
libxml_use_internal_errors(true
);
libxml_clear_errors();
$dom =
new \
DOMDocument();
$dom->
loadXML($data,
$context[self::LOAD_OPTIONS
] ??
$this->defaultContext
[self::LOAD_OPTIONS
]);
libxml_use_internal_errors($internalErrors);
if ($error =
libxml_get_last_error()) {