| @@ 44-75 (lines=32) @@ | ||
| 41 | * @param \SimpleXMLElement $xml |
|
| 42 | * @param array $array |
|
| 43 | */ |
|
| 44 | protected function arrayToSimpleXml(\SimpleXMLElement $x, array $array) |
|
| 45 | { |
|
| 46 | foreach ($array as $k => $v) { |
|
| 47 | if (is_array($v)) { |
|
| 48 | if (is_int($k)) { |
|
| 49 | $k = $this->items_key; |
|
| 50 | } |
|
| 51 | ||
| 52 | // @codeCoverageIgnoreStart |
|
| 53 | // Attributes needs to be reviewd!!! |
|
| 54 | #if ($k == '@attributes') { |
|
| 55 | # foreach ($v as $k => $v) { |
|
| 56 | # $x->addAttribute($k, $v); |
|
| 57 | # } |
|
| 58 | // @codeCoverageIgnoreEnd |
|
| 59 | #} else { |
|
| 60 | $child = $x->addChild($k); |
|
| 61 | $this->arrayToSimpleXml($child, $v); |
|
| 62 | #} |
|
| 63 | } else { |
|
| 64 | if (is_int($k)) { |
|
| 65 | $k = $this->item_key; |
|
| 66 | } |
|
| 67 | ||
| 68 | // $xml->addAttribute( |
|
| 69 | // $k, |
|
| 70 | // htmlspecialchars($v, ENT_QUOTES, $this->encoding) |
|
| 71 | // ) |
|
| 72 | $x->addChild($k, $this->specialChars($v)); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * Decodes any special characters entities. |
|
| @@ 45-63 (lines=19) @@ | ||
| 42 | * @param array $array |
|
| 43 | * @see https://bugs.php.net/bug.php?id=63589 |
|
| 44 | */ |
|
| 45 | protected function arrayToXmlWriter(\XmlWriter $x, array $array) |
|
| 46 | { |
|
| 47 | foreach ($array as $k => $v) { |
|
| 48 | // replace numeric index key to 'item' e.g. <results><item>...</item></results> |
|
| 49 | if (is_array($v)) { |
|
| 50 | if (is_int($k)) { |
|
| 51 | $k = $this->items_key; |
|
| 52 | } |
|
| 53 | $x->startElement($k); |
|
| 54 | $this->arrayToXmlWriter($x, $v); |
|
| 55 | $x->endElement(); |
|
| 56 | } else { |
|
| 57 | if (is_int($k)) { |
|
| 58 | $k = $this->item_key; |
|
| 59 | } |
|
| 60 | $x->writeElement($k, $v); // XmlWriter bug |
|
| 61 | } |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | } |
|
| 66 | ||