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.x sl";
public static void Main()
{
XslTransform xslt = new XslTransform();
xslt.Load(style sheet);
XPathDocument xpathdocument = new
XPathDocument(f ilename);
XmlTextWriter writer = new XmlTextWriter(C onsole.Out);
writer.Formatti ng=Formatting.I ndented;
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. 1 3576
I found myselft, thanks any way.
public string TransformXml(st ring aXml, string aXsl)
{
string Result = "";
XmlDocument xml = new XmlDocument();
XmlDocument xsl = new XmlDocument();
xml.LoadXml(aXm l);
xsl.LoadXml(aXs l);
//creating xslt
XslTransform xslt = new XslTransform();
xslt.Load(xsl, null,null) ;
//creating stringwriter
StringWriter writer = new System.IO.Strin gWriter();
//Transform the xml.
xslt.Transform( xml, null, writer, null);
//return string
Result = writer.ToString ();
writer.Close();
return Result;
}
"Owen" <an****@prens a-latina.cu> wrote in message
news:OZ******** ******@TK2MSFTN GP12.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.x sl";
public static void Main() { XslTransform xslt = new XslTransform(); xslt.Load(style sheet); XPathDocument xpathdocument = new XPathDocument(f ilename); XmlTextWriter writer = new XmlTextWriter(C onsole.Out); writer.Formatti ng=Formatting.I ndented;
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 pointer which cannot be used
with strlwr() as it does the conversion inplace. So, I use the
following logic of copying the contents to a dynamically allocated
char* array and then doing the conversion:
-----------------------------
|
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";
wstring output;
|
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 XML.
I need to take that string, apply the XSLT to it, and get the output into a
string suitable for writing out to a tcp port.
Essentially, an XML string, transformed into another string.
|
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, such as a div with
a runat=server. I can somewhat do this if I create a server control
and include the control within the html
div tag but this method (borrowed from ASP.NET Website Programming by
Wrox press thanks guys) does not give me
the full...
|
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 transforms small XML into quite big XML. Now, I have a straightforward
C# (see below) code that does this transform and writes result into XmlTextWriter.
(Oleg's NXSLT.EXE is also suitable).
| |
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 case i have everything in
string
|
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#)
Regards,
Reddy
|
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 string without writing to a
file and then reading back from the file (not to lose out
on performance).
Thank you for your help in advance.
|
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 (doc) and dumps out the XML.
What I'd like to do is isntead of having it just dump the HTML, have it sent
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |