Problems with XPathDocument

C

C#Schroeder

First off I want to thank all that have helped me in the past. I am
new to working with XML in .Net.

I have another problem right now with my code.

Background: I am trying to create a HTML document from some forms from
a window application. I am creating a XML document from the forms,
using a XSLT document, and populate a Web Broswer with the created
HTML document. I want to create the XML document and HTML in memory
rather then using a temporary file. I have crated the XML document in
memory and have it saved as a string. I have code that I believe will
create the HTML document in memory, however I am running into a
problem with the XPathDocument. I get a
System.NullReferenceException.

Here is my code:

public void XSLTtoHTML(string serializeDay)
{
XPathDocument input = new XPathDocument(new
StringReader(serializeDay));
XslCompiledTransform myXslTransform = new
XslCompiledTransform();
myXslTransform.Load("C:/myXmFile.xsl");
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
myXslTransform.Transform(input, null, sw);

XmlDocument page = new XmlDocument();
byte[] bytes = ms.ToArray();
string transformedXml = Encoding.UTF8.GetString(bytes);
page.LoadXml(transformedXml);
sw.Dispose();
ms.Close();
ms.Dispose();

}

Thanks for the help
 
P

Patrick Steele

I have crated the XML document in
memory and have it saved as a string. I have code that I believe will
create the HTML document in memory, however I am running into a
problem with the XPathDocument. I get a
System.NullReferenceException.

Where? You didn't indicate what line of code produces the exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top