473,938 Members | 14,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.NullRefe renceException.

Here is my code:

public void XSLTtoHTML(stri ng serializeDay)
{
XPathDocument input = new XPathDocument(n ew
StringReader(se rializeDay));
XslCompiledTran sform myXslTransform = new
XslCompiledTran sform();
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.G etString(bytes) ;
page.LoadXml(tr ansformedXml);
sw.Dispose();
ms.Close();
ms.Dispose();

}

Thanks for the help

Mar 8 '07 #1
1 1994
In article <11************ **********@c51g 2000cwc.googleg roups.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.NullRefe renceException.
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
5650
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: XmlReader instance from another module (beyond my control)
2
3722
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 public inside the class)
8
2467
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 single XPathDocument which is then transformed throughout the web site with different XslTransformations. I realize that the Xpathdocument will accept a XmlReader as an object but I have 5 of them so how to 'best' combine. The resulting...
1
1933
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 specify the XML input file and output file, I get the same error. The error is: An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error. Here's my code... commented to show where...
2
11943
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 node I get back the "values" of the child nodes but no formatted xml which I need for transformations later in the sequence. Is there a way to pull pure xml from the xpathdocument?
3
561
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 page it doesn't work. Here's a condensed example of what I am talking about. If I run this code in a console app the "count" variable will have a value equal to the number of book nodes in "books.xml". When I run the same code in an aspx page...
2
2489
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 having problems doing same procedures I do with XPathDocuments in XPathDocuments. I have a configuration XML document, which holds all the configuration information for an application (see below sample). I extract the information from the...
0
1065
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 to supply a variable instead of the xml doc. This is the code I use: dim docNav As XPathDocument docNav = New XPathDocument("c:\adsp_dispatch.xml") I would like to use something like:
5
6296
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 than XmlDocument. I've run the tests several times and have tried to eliminate extraneous variables like disk access but every time, XPathDocument comes up slower by a few percent. I'd expected it to be faster since it's a read-only...
0
9963
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11515
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11282
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9854
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7377
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6287
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.