The following blog gives a neat example of how to transform directly into a
node:
http://blogs.msdn.com/xmlteam/
However, the code doesn't seem to work as it is presented in the blog. I
have put together the following three test cases to show this. The first two
work correctly, the last one doesn't. BTW...the last one is codes according
to the blog entry.
------------------------------
System.Xml.Xsl.XslCompiledTransform xslt = new
System.Xml.Xsl.XslCompiledTransform();
System.Xml.XmlDocument OutputDoc = null;
System.Xml.XmlWriter w = null;
xslt.Load(@"test.xslt");
OutputDoc = new System.Xml.XmlDocument();
using (w = OutputDoc.CreateNavigator().AppendChild()) {
xslt.Transform(@"test.xml", null, w);
}
OutputDoc.Save(@"out1.xml");
OutputDoc = new System.Xml.XmlDocument();
w = OutputDoc.CreateNavigator().AppendChild();
xslt.Transform(@"test.xml", null, w);
w.Flush();
w.Close();
OutputDoc.Save(@"out2.xml");
OutputDoc = new System.Xml.XmlDocument();
xslt.Transform(@"test.xml", null,
OutputDoc.CreateNavigator().AppendChild());
OutputDoc.Save(@"out3.xml");