XmlTransformation output to string
-
I have to use xml transformation. The simplest way is
XslTransform xsltransform = new XslTransform(); xsltransform.Load("favorite.xsl"); xsltransform.Transform("MyDocument.xml", "TransformResult.xml");
But it is necessery for me to put output of transformation not to file but to string... (all of overloaded members of Transform has file or stream) Do you have any idea? -
I have to use xml transformation. The simplest way is
XslTransform xsltransform = new XslTransform(); xsltransform.Load("favorite.xsl"); xsltransform.Transform("MyDocument.xml", "TransformResult.xml");
But it is necessery for me to put output of transformation not to file but to string... (all of overloaded members of Transform has file or stream) Do you have any idea?tomiga wrote: (all of overloaded members of Transform has file or stream) You could create a memory stream to house the output of the transformation; then once the transformation is done convert the underlying byte array to a string.
System.Text.(Encoding).GetString(myByteArray)
if the XML file uses ASCII then (Encoding) should be ASCIIEncoding; if it uses UTF8 then it should be UTF8Encoding; etc... James "Java is free - and worth every penny." - Christian Graus -
tomiga wrote: (all of overloaded members of Transform has file or stream) You could create a memory stream to house the output of the transformation; then once the transformation is done convert the underlying byte array to a string.
System.Text.(Encoding).GetString(myByteArray)
if the XML file uses ASCII then (Encoding) should be ASCIIEncoding; if it uses UTF8 then it should be UTF8Encoding; etc... James "Java is free - and worth every penny." - Christian Graus