normalizeXMLTag example


    protected function arrayToXML(array $data, &$output)
    {
        foreach ($data as $key => $value) {
            $key = $this->normalizeXMLTag($key);

            if (is_array($value)) {
                $subnode = $output->addChild("{$key}");
                $this->arrayToXML($value$subnode);
            } else {
                $output->addChild("{$key}", htmlspecialchars("{$value}"));
            }
        }
    }

    /** * Normalizes tags into the allowed by W3C. * Regex adopted from this StackOverflow answer. * * @param int|string $key * * @return string * * @see https://stackoverflow.com/questions/60001029/invalid-characters-in-xml-tag-name */
Home | Imprint | This part of the site doesn't use cookies.