protected function parseArgs($args) { $attributes = array(); $content = ''; foreach ($args as $arg) { if (is_string($arg)) { $content .= $this->escape($arg); } else { if (is_array($arg)) { foreach ($arg as $key => $subArg) { if (is_numeric($key)) { list($subattributes, $subcontent) = $this->parseArgs($subArg); $attributes = array_merge($attributes, $subattributes); $content = \arc\xml::raw($content . $subcontent); } else { $attributes[$key] = $subArg; } } } else { $content .= $arg; } } } return [$attributes, $content]; }
function testXMLWriterEscaping() { $xml = \arc\xml::item(['class' => 'in"valid<stuff>', 'inva"lid' => "this is \n just wrong"], "Escape me\" < really ©" . chr(8), \arc\xml::subitem(\arc\xml::raw("<subsubitem>this should work</subsubsubitem>"))); $expectedValue = <<<EOF <item class="in"valid<stuff>" invalid="this is just wrong"> \tEscape me" < really &copy;<subitem> \t\t<subsubitem>this should work</subsubsubitem> \t</subitem> </item> EOF; $this->assertEquals($expectedValue, (string) $xml); }