https://bugzilla.novell.com/show_bug.cgi?id=372525
Summary: XmlStringWriter fails for StringWriter without Encoding.
Product: Mono: Class Libraries
Version: 1.2.4
Platform: x86
OS/Version: Ubuntu
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.XML
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
Found By: ---
System.Xml.XmlStringWriter has a constructor taking a StringWriter
by default this generates a string containing xml, the xml header uses the
encoding provided by the Encoding property of the StringWriter.
If this property is null .net removes the encoding from the xmlheader.
mono gives a nullpointer exception.
private class EncodingLessStringWriter : StringWriter
{
public override Encoding Encoding
{ get { return null; } }
}
// only use this to embed xml into another document that controls the
character encoding (ie. xml or a string)
public string AsXmlWithoutEncoding()
{
StringWriter stringWriter = new EncodingLessStringWriter();
XmlTextWriter writer = new XmlTextWriter(stringWriter);
writer.Formatting = Formatting.None;
XmlDocument doc = new XmlDocument();
XmlNode n = CreateDomAsXmlNode(doc);
doc.AppendChild(n);
doc.Save(writer);
return stringWriter.GetStringBuilder().ToString();
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs