[Mono-bugs] [Bug 372525] New: XmlStringWriter fails for StringWriter without Encoding.
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Mar 19 15:56:26 EDT 2008
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: atsushi at ximian.com
ReportedBy: bluelive at gmail.com
QAContact: mono-bugs at lists.ximian.com
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.
More information about the mono-bugs
mailing list