Hi Oleg and All,
Is this correct? Can I do this?
<code>
XmlDocument doc=new XmlDocument();
XPathNavigator nav = doc.CreateNavig ator();
//Load the xml file. Change path if needed
doc.Load(@"..\. .\..\books.xml" );
XslTransform xslt = new XslTransform();
xslt.Load(@"D:\ XML\XSL Ex2\Personnel2. xsl");
StringWriter fs = new StringWriter();
xslt.Transform( doc, null, fs, null);
XmlNode node=doc.Select SingleNode("boo kstore"); <-
Here is the problem
</code>
I need to transform the XML First using xslt.transform
then take the resulting XML and assign it to an XmlNode.
How should this be done?
Thanks,
JJBean :) 6 5704
I guess my question is worded wrong. This line :
XmlNode node=doc.Select SingleNode("boo kstore"); <- Here
is the problem
in my code. At this point does "doc" have the xslt
applied to it so that I am working with the resulting xml
in DOC?
JJ -----Original Message-----
Hi Oleg and All,
Is this correct? Can I do this?
<code>
XmlDocument doc=new XmlDocument(); XPathNavigator nav = doc.CreateNavig ator(); //Load the xml file. Change path if needed doc.Load(@"..\. .\..\books.xml" ); XslTransform xslt = new XslTransform(); xslt.Load(@"D:\ XML\XSL Ex2\Personnel2. xsl"); StringWriter fs = new StringWriter(); xslt.Transform( doc, null, fs, null);
XmlNode node=doc.Select SingleNode("boo kstore"); <- Here is the problem
</code>
I need to transform the XML First using xslt.transform then take the resulting XML and assign it to an
XmlNode.How should this be done?
Thanks,
JJBean :)
.
This is really frustrating.
How do u apply a XSLT transform to an XmlDocument in c#?
Could you show me this in code ? I'm sure it's only
acouple of lines but can't find any examples on it.
Thanks,
JJ -----Original Message-----
Hi Oleg and All,
Is this correct? Can I do this?
<code>
XmlDocument doc=new XmlDocument(); XPathNavigator nav = doc.CreateNavig ator(); //Load the xml file. Change path if needed doc.Load(@"..\. .\..\books.xml" ); XslTransform xslt = new XslTransform(); xslt.Load(@"D:\ XML\XSL Ex2\Personnel2. xsl"); StringWriter fs = new StringWriter(); xslt.Transform( doc, null, fs, null);
XmlNode node=doc.Select SingleNode("boo kstore"); <- Here is the problem
</code>
I need to transform the XML First using xslt.transform then take the resulting XML and assign it to an
XmlNode.How should this be done?
Thanks,
JJBean :)
.
JJ wrote: I guess my question is worded wrong. This line :
XmlNode node=doc.Select SingleNode("boo kstore"); <- Here is the problem
in my code. At this point does "doc" have the xslt applied to it so that I am working with the resulting xml in DOC?
Not really. XSLT never changes input XML. As per
xslt.Transform( doc, null, fs, null);
the result was written to fs.
--
Oleg Tkachenko
XML Insider http://www.tkachenko.com/blog
JJ wrote: How do u apply a XSLT transform to an XmlDocument in c#?
Applying transformation doesn't mean modification of the input
XmlDocument. XmlDocument in your code is "source" XML in XSLT terms. The
result is never the same as source.
Actually I can imangine XSL transformation to be appended directly to
the input DOM, via XmlNodeWriter class:
XmlDocument doc = new XmlDocument();
doc.Load("input .xml");
XslTransform xslt = new XslTransform();
xslt.Load("test .xsl");
XmlNodeWriter nw = new XmlNodeWriter(d oc.DocumentElem ent, false);
xslt.Transform( doc, null, nw);
nw.Close();
doc.Save(Consol e.Out);
Above transformation appends result to the input DOM. Just tried, seems
to be working. Of course it could be dangerous, say you can replace
input data with result data prior they are processed.
--
Oleg Tkachenko
XML Insider http://www.tkachenko.com/blog
Hi Oleg,
I am interested in why you chose to use XmlNodeWriter
as the writer and not like Xmlwriter or streamwriter?
Thanks for helping me out Oleg, I really appreciate it!
And you have really wet my appetite on using XML. It's
pretty kool.
Thanks,
JJ -----Original Message----- JJ wrote:
How do u apply a XSLT transform to an XmlDocument in
c#? Applying transformation doesn't mean modification of the
inputXmlDocument. XmlDocument in your code is "source" XML in
XSLT terms. Theresult is never the same as source. Actually I can imangine XSL transformation to be
appended directly tothe input DOM, via XmlNodeWriter class:
XmlDocument doc = new XmlDocument(); doc.Load("inpu t.xml"); XslTransform xslt = new XslTransform(); xslt.Load("tes t.xsl"); XmlNodeWrite r nw = new XmlNodeWriter
(doc.DocumentEl ement, false);xslt.Transform (doc, null, nw); nw.Close(); doc.Save(Conso le.Out);
Above transformation appends result to the input DOM.
Just tried, seemsto be working. Of course it could be dangerous, say you
can replaceinput data with result data prior they are processed. -- Oleg Tkachenko XML Insider http://www.tkachenko.com/blog
.
JJ wrote: I am interested in why you chose to use XmlNodeWriter as the writer and not like Xmlwriter or streamwriter?
Because I wanted to write to XmlDocument. And after all XmlNodeWriter is
XmlWriter. But when using StreamWriter, there is an superfluous overhead
of serializing and reparsing XML back to DOM. Using XmlNodeWriter you
can write directly to DOM with no any interim buffers.
--
Oleg Tkachenko
XML Insider http://www.tkachenko.com/blog This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 instruction
document (not data based) - same as using an xml web control.
The resulting html is on the client? but what about the server side of
things? Trying to figure out how to change and save the xmlDocument.
It I put a button OUTSIDE of the...
|
by: Martin Honnen |
last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour
where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing
a text node with a character reference to an invalid characters like .
Using the CreateTextNode method I create a text node containing
"\u0001a" (C# string literal notation). As far as I understand the DOM
allows that and an implementation is not required to throw an error.
When OuterXml is...
|
by: Robert Rossney |
last post by:
I'm trying to send and receive XmlDocument objects using the
System.Messaging.dll functions. The code I've written follows, as best I
can tell, the methodology used in the sample code for the
XmlMessageFormatter class. But it isn't working -- specifically, receiving
isn't working. What am I doing wrong here?
I begin by creating a MessageQueue object and setting up its
XmlMessageFormatter to handle XmlDocument objects:
System.Type...
|
by: Graham Pengelly |
last post by:
Hi
I am trying to transform on System.Xml.XmlDocument into another using
XslTransform without writing the object out to a file. I am guessing it
should work something like this...
public XmlDocument TransformXmlDoc(XmlDocument docToTransform, string
xsltFilePath)
{
//load the xslt
|
by: Dave |
last post by:
Hi,
Is there an easier way to pull a subset of nodes from one XmlDocument to
another? I have the code below but would like to know if there is a more
streamlined method. Thanks, Dave
XmlNodeList nodeList = doc1.SelectNodes("//row");
foreach (XmlNode nodeCode in nodeList)
{
sb.Append(nodeCode.OuterXml);
| |
by: pete |
last post by:
Hi there,
Can someone explain to me why I can't bind to an XmlDocument but I can bind
to an XmlNodeList. It's my understanding that they both implement the
IEnumerable interface which is required for databinding. Am happy to work
with the XmlNodeList but I can't shake the feeling I'm missing something
<blush>
Thanks, Pete
|
by: Peter Nofelt |
last post by:
Hey All,
I'm running into this issue with parsing through an xml document by
tag name. Below is an example xml document:
File Name: things.xml
<things>
<people>
<name>Peter</name>
|
by: David |
last post by:
I need to find a good online resource which teaches the use of the
XmlDocument framework in more depth than is covered in MS's online
doc. I need to create a multi-level XML document like the one listed
below. Using XmlDocument, I can create the <books> and the individual
<name> and <price> elements, but I am unsure how to create the
<category> and <title> elements and close them after creating the
detail elements. Eg. how can I go 2+...
|
by: Rob Panosh |
last post by:
Hello,
I am trying to create a xmlDocument from as dataset. My code is listed
below. All seems to go well until
xmlDocument.Load(CType(ms, System.IO.Stream)) ... I keep getting the
following error "The Root Element is Missing" ... any help would be
appreciated.
Thanks,
Rob Panosh
|
by: John Smith |
last post by:
I'm writing webervice client using .Net 2.0. I have this class:
public class MyWebService : SoapHttpClientProtocol
{
public XmlDocument validate(string url,
XmlDocument xmlDocument)
{
this.Url = url;
|
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: 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: 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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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
| |
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...
| |