Here's some C# code:
var sb = new StringBuilder();
var w = XmlWriter.Create(sb);
w.WriteStartElement("hello");
w.WriteAttributeString("target", "world ' \" !");
w.WriteEndElement();
w.Flush();
// then look at sb.ToString()
I'm getting a string that looks like:
<?xml version="1.0" encoding="utf-16"?><hello target="world ' " !" />
It's only escaping the double-quote, not the single-quote. But the docs for XmlWriter.WriteAttributeString(String, String) say:
If the attribute value includes double or single quotes, they are replaced with " and ' respectively.
Is there some flag I need to set to make it do what the docs say it does?