473,385 Members | 1,893 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,385 software developers and data experts.

in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my case i have everything in string

in C# how do i transform an xml document with an xsl document when my xml
document is a string and my xsl document is a string? the msdn examples only
show how to do it with steams and files. in my case i have everything in
string
Nov 17 '05 #1
3 1766
Seems like your whole posting is on subject line. Is that what subject text
box is used for?
"Daniel" <so*******************@yahoo.com> wrote in message
news:um**************@TK2MSFTNGP10.phx.gbl...
in C# how do i transform an xml document with an xsl document when my xml
document is a string and my xsl document is a string? the msdn examples
only
show how to do it with steams and files. in my case i have everything in
string

Nov 17 '05 #2
You can create an XmlReader from a TextReader, then use that for both
the document and the transform:

System.IO.TextReader docTextReader = new
System.IO.StringReader(xmlString);
System.Xml.XmlReader docReader = new
System.Xml.XmlReader(docTextReader);
System.Xml.XPathDocument doc = new System.Xml.XPathDocument(docReader);
System.IO.TextReader xslTextReader = new
System.IO.StringReader(xslString);
System.Xml.XmlReader xslReader = new
System.Xml.XmlReader(xslTextReader);
System.Xml.Xsl.XslTransform transform = new
System.Xml.Xsl.XslTransform();
transform.Load(xslReader);
XmlReader transformedXmlReader = transform.Transform(doc, new
System.Xml.Xsl.XsltArgumentList(), new XmlUrlResolver());

I've used fully-qualified names everywhere so that you can see where
the classes are defined. Of course, you would use "using" directives
and simple class names instead.

Nov 17 '05 #3
You can create an XmlReader from a TextReader, then use that for both
the document and the transform:

System.IO.TextReader docTextReader = new
System.IO.StringReader(xmlString);
System.Xml.XmlReader docReader = new
System.Xml.XmlReader(docTextReader);
System.Xml.XPathDocument doc = new System.Xml.XPathDocument(docReader);
System.IO.TextReader xslTextReader = new
System.IO.StringReader(xslString);
System.Xml.XmlReader xslReader = new
System.Xml.XmlReader(xslTextReader);
System.Xml.Xsl.XslTransform transform = new
System.Xml.Xsl.XslTransform();
transform.Load(xslReader);
XmlReader transformedXmlReader = transform.Transform(doc, new
System.Xml.Xsl.XsltArgumentList(), new XmlUrlResolver());

I've used fully-qualified names everywhere so that you can see where
the classes are defined. Of course, you would use "using" directives
and simple class names instead.

Nov 17 '05 #4

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

Similar topics

6
by: Richard Koch | last post by:
Hi folks! I want to transform a XML document using a XLS stylesheet (transformNodeToObject()). I did my code as the MSDN examples suggest, the transformation succeeds S_OK. Unfortunately, the...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
1
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my...
5
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
6
by: Bill Cohagan | last post by:
I've got a c# app that does some transforms using XSL files that are stored as Embedded Resources in the app. That turns out to be significant; i.e., the problem I've encountered goes away if I...
1
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my...
3
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty...
9
by: Doug Stiers | last post by:
I have this vb.net (framework 1.1) code: Dim x As Xml.Xsl.XslTransform = New Xml.Xsl.XslTransform Dim xr As XmlResolver MessageBox.Show("before load") x.Load(<xsl file name>) -- THIS IS WHERE...
3
by: Peter Row | last post by:
Hi, I have 2 XML files and 1 XSLT file. The second XML file has the following declarative 1st line: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ....the 1st one (the one to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.