Skip to content

Commit 18394f1

Browse files
committed
fixed error on null value
1 parent a679372 commit 18394f1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ArrayToXmlFile.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ private function convertElement($value, $siblingKey = null)
107107
{
108108
$sequential = $this->isArrayAllKeySequential($value);
109109

110-
if (! is_array($value)) {
110+
if (!is_array($value)) {
111111
$value = $value;
112112

113-
$value = $this->removeControlCharacters($value);
113+
if (!is_null($value)) {
114+
$value = $this->removeControlCharacters($value);
114115

115-
$this->writer->text($value);
116+
$this->writer->text($value);
117+
}
116118

117119
return;
118120
}
@@ -240,7 +242,7 @@ protected function startElement($name)
240242
try {
241243
$result = $this->writer->startElement($name);
242244
} catch (exception $e) {
243-
throw new DOMException($e->getMessage());
245+
throw new DOMException("'{$name}': {$e->getMessage()}");
244246
}
245247
if (!$result)
246248
throw new DOMException(error_get_last());

0 commit comments

Comments
 (0)