Skip to content

Commit

Permalink
Update XMLReader.php
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 authored Jan 11, 2018
1 parent a5bda6b commit 390c8c4
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/XMLReader/XMLReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ public function asXML($storage, $name = 'bavix', array $attributes = [])
{
$element = $this->element($name);

foreach ($attributes as $attr => $value) {
$element->setAttribute($attr, $value);
}

$this->addAttributes($element, $attributes);
$this->addAttributes($element, $this->copyright);
$this->document()->appendChild($element);
$this->convert($element, $this->_convertStorage($storage));
Expand Down Expand Up @@ -295,9 +292,30 @@ protected function addNodeWithKey($key, DOMElement $element, $storage)
{
$this->addAttributes($element, $storage);
}
else if ($key === '@value' && \is_string($storage))
else if ($key === '@value')
{
$element->nodeValue = \htmlspecialchars($storage);
if (\is_string($storage))
{
$element->nodeValue = \htmlspecialchars($storage);

return;
}

$dom = new \DOMDocument();
$dom->loadXML(
(new XMLReader())->asXML($storage)
);

$fragment = $element->ownerDocument->createDocumentFragment();

foreach ($dom->firstChild->childNodes as $value)
{
$fragment->appendXML(
$value->ownerDocument->saveXML($value)
);
}

$element->appendChild($fragment);
}
else
{
Expand Down

0 comments on commit 390c8c4

Please sign in to comment.