473,383 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problems with XPathDocument

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

Mar 8 '07 #1
1 1940
In article <11**********************@c51g2000cwc.googlegroups .com>,
An***************@gray-research.com says...
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.

--
Patrick Steele
http://weblogs.asp.net/psteele
Mar 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: xmlguy | last post by:
I believe this should be pretty elementary, but for some reason I cannot seem to think of how to write the an XML file from an incoming XML file. Basically this is what I do: Input: ...
2
by: xmlguy | last post by:
Cant seem to solve this problem I need to be able to re-use XmlReader and XPathDocument for an XSLT Transform. Basically I have defined following interfaces: Class Render (Common and...
8
by: Keith Chadwick | last post by:
My problem is this. I have to create several xmlReader objects each retrieving 'for xml' formatted sql server data. I then need to peice them together into a single document and place them into a...
1
by: Andrew Connell | last post by:
I have an XML document and an XSLT transformation sheet. My first issue is that my XML file won't load into the XPathDocument object. However, when I use an obsolete transformation method where I...
2
by: Robert Strickland | last post by:
I load an xml stream into a xpathdocument type, compile a xpath expression and select to specific node. I find the node and wish to return the innerxml of that node. When I use value of the current...
3
by: Marri Suliez | last post by:
I am trying to run the asp xpath examples from the QuickStarts samples, but I am not having any luck. When I run the code in a console app it works fine. When I run the same exact code in an aspx...
2
by: Jim Lewis | last post by:
After everything I have read and some of my own testing I am convinced that XPathDocument are more efficient if you are only using XML for read only and not modifying the XML. However, I have been...
0
by: Joe Pannone | last post by:
I need a way to allow a variable to equal an xml document. When using xpathdocument the parameter is asking for a filename. Since I plan on doing a lot of search in the xml document I would like...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've been trying to improve the performance of our xml handling, so I've been doing some timing tests lately and ran across something I thought odd - XPathDocument seems slightly slower...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.