The WriteRaw method of the XPathDocumentWriter escapes the XML brackets < and > to < and > It seems that it behaves exactly as WriteString does.
Steps to reproduce:
XPathDocumentWriter xw = new XPathDocumentWriter();
xw.WriteStartElement("root");
xw.WriteRaw("<item>test</item>");
xw.WriteEndElement();
xw.Flush();
XPathNavigator xn = xw.Close();
Trace.WriteLine(xn.OuterXml);
The output is:
<root><item>test<item></root>
Whereas it should be:
<root><item>test</item></root>
Comments: Look in Reflector at the MS.Internal.Xml.Cache.XPathDocumentBuilder.WriteRaw implementation:
public override void WriteRaw(string data)
{
this.WriteString(data, TextBlockType.Text);
}
That's the wrapped class we're calling, it's provided by .NET and we can't change its behavior. So I guess you cannot use WriteRaw.
An alternative would be to parse the string with an XmlReader and use WriteNode instead.
Steps to reproduce:
XPathDocumentWriter xw = new XPathDocumentWriter();
xw.WriteStartElement("root");
xw.WriteRaw("<item>test</item>");
xw.WriteEndElement();
xw.Flush();
XPathNavigator xn = xw.Close();
Trace.WriteLine(xn.OuterXml);
The output is:
<root><item>test<item></root>
Whereas it should be:
<root><item>test</item></root>
Comments: Look in Reflector at the MS.Internal.Xml.Cache.XPathDocumentBuilder.WriteRaw implementation:
public override void WriteRaw(string data)
{
this.WriteString(data, TextBlockType.Text);
}
That's the wrapped class we're calling, it's provided by .NET and we can't change its behavior. So I guess you cannot use WriteRaw.
An alternative would be to parse the string with an XmlReader and use WriteNode instead.