According to the documentation having & in a tag will be turned to &
http://digitalmars.com/d/2.0/phobos/std_xml.html#text I observe that this is not the case. And if an attribute contains & it is turned into &amp; What is the best way to receive the same output for both. The code that follows outputs Attr: What &amp; Up Elem: What & Up *testfile.xml:* <?xml version="1.0" encoding="utf-8"?> <Tests> <Test thing="What & Up">What & Up</Test> </Tests> *test.d:* import std.stdio; import std.xml; void main() { auto file = "testfile.xml"; auto s = cast(string)std.file.read(file); auto xml = new DocumentParser(s); xml.onStartTag["Test"] = (ElementParser xml) { writeln("Attr: ", xml.tag.attr["thing"]); }; xml.onEndTag["Test"] = (in Element e) { writeln("Elem: ", e.text); }; xml.parse(); }