Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  Mvp.Xml Project  EXSLT.NET  How do I get th...
 How do I get the XML string?
 
CA
4 posts
Joined
1/26/2006

How do I get the XML string?
Posted: 29 Jan 06 4:40 AM (United Kingdom)
How do I get the XML string out of the MvpXmlTransform?

The sample code provided is this:

using System;
using System.Xml.XPath;
using Mvp.Xml.Common.Xsl;

public class ExsltTest
{
public static void Main()
{
MvpXslTransform xslt = new MvpXslTransform();
xslt.Load("foo.xsl");
xslt.Transform(new XmlInput("foo.xml"), new XmlOutput("result.html"));
}
}

But instead of outputting the XML to a file I want to do some in-memory string processing on it. But I haven't found a way of getting to it.
n.b. I want to handle it as a string, not as an XML document.

Is there some XmlOutput class that wraps a string variable? Or is there some XmlReader class that does the same?
olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: How do I get the XML string?
Posted: 29 Jan 06 6:14 AM (Israel)

You need StringWriter class:

MvpXslTransform xslt = new MvpXslTransform();

xslt.Load("../../style.xsl");

StringWriter sw = new StringWriter();

xslt.Transform(new XmlInput("../../source.xml"), null, new XmlOutput(sw));

sw.Close();

string result = sw.ToString();

Console.WriteLine(result);


Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
  Mvp.Xml Project  EXSLT.NET  How do I get th...
Forum Home  Search