PHP DOMDocument::save() saves as ASCII instead of UTF-8
问题 I'm using DOMDocument and SimpleXMLElement to create a formatted XML file. While this all works, the resulting file is saved as ASCII, not as UTF-8. I can't find an answer as to how to change that. The XML is created as so: $XMLNS = "http://www.sitemaps.org/schemas/sitemap/0.9"; $rootNode = new \SimpleXMLElement("<?xml version='1.0' encoding='UTF-8'?><urlset></urlset>"); $rootNode->addAttribute('xmlns', $XMLNS); $url = $rootNode->addChild('url'); $url->addChild('loc', "Somewhere over the