473,396 Members | 2,018 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,396 software developers and data experts.

string XML transform

Hello:

I have some xml and xsl in string, "not in file". I want to transform the
xml with xsl and the result I want in string (but in xml format). I read
this sample :

public class Sample
{
private const String filename = "mydata.xml";
private const String stylesheet = "myStyleSheet.xsl";

public static void Main()
{
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);
XPathDocument xpathdocument = new
XPathDocument(filename);
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting=Formatting.Indented;

xslt.Transform(xpathdocument, null, writer, null);
}

And read the class help, but I can found my soluction (maybe I don't so
wise).
Please Help me.

Best regards.
Owen.
Nov 12 '05 #1
1 3554
I found myselft, thanks any way.

public string TransformXml(string aXml, string aXsl)
{
string Result = "";
XmlDocument xml = new XmlDocument();
XmlDocument xsl = new XmlDocument();
xml.LoadXml(aXml);
xsl.LoadXml(aXsl);

//creating xslt
XslTransform xslt = new XslTransform();
xslt.Load(xsl, null,null) ;

//creating stringwriter
StringWriter writer = new System.IO.StringWriter();

//Transform the xml.
xslt.Transform(xml, null, writer, null);

//return string
Result = writer.ToString();
writer.Close();

return Result;
}

"Owen" <an****@prensa-latina.cu> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Hello:

I have some xml and xsl in string, "not in file". I want to transform the
xml with xsl and the result I want in string (but in xml format). I read
this sample :

public class Sample
{
private const String filename = "mydata.xml";
private const String stylesheet = "myStyleSheet.xsl";

public static void Main()
{
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);
XPathDocument xpathdocument = new
XPathDocument(filename);
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting=Formatting.Indented;

xslt.Transform(xpathdocument, null, writer, null);
}

And read the class help, but I can found my soluction (maybe I don't so
wise).
Please Help me.

Best regards.
Owen.

Nov 12 '05 #2

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

Similar topics

37
by: Zombie | last post by:
Hi, what is the correct way of converting contents of a <string> to lowercase? There are no methods of <string> class to do this so I fallback on strlwr(). But the c_str() method returns a const...
3
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING";...
3
by: Christopher Ambler | last post by:
This has to be a FAQ, but I can't seem to find the answer anywhere! I have an application that consumes a web service that returns me a string full of XML. I also have an XSLT for outputting the...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
1
by: Yuriy | last post by:
Hi, Can anybody explain the following? Say I have the following source XML and XSLT (see below). No matter what this XSLT does. It is just a sample to show a problem. the idea is that XSLT...
3
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...
1
by: Srinivasa Reddy K Ganji | last post by:
Hi I want to encrypt the database connection string and add it to web.config file. Before connecting to the database I want to decrypt it. Can anyone suggest me how to implement this (c#) ...
1
by: Krista Lemieux | last post by:
Hello, I am trying to transform XML with XSL to a string in .NET. Currently I am using XSLTransform class, but all the Transform() methods write to a file. How can I Transform it straight to a...
2
by: darrel | last post by:
I don't do a lot with XML, so I always get a bit lost navigating the XML classes. In the past, I've used this: xslt.Transform(doc, xslArg, Response.Output, Nothing) Which takes my xml file...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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...

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.