Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Simple XML to XML Transformation

vb.net 2003, .net 1.1

My application is intended to receive xml data from a variety of sources.  Each xml data packet is loaded into an XmlDocument.

I now need to convert the xml in this XmlDocument object and load the result into a new XmlDocument. (XmlDoc -> XSLT -> NewXmlDoc)

 - The XSLT for this transform is located on a public server: "http://myserver.mycompany.com/files/my.xslt"
 - All xml data needs to be handled in memory, and not saved to the file system.

Does anyone have a completed example of this (in either c# or vb)?  I have struggled to find an example that doesn't involves the source xml being on the file system.

TIA,
0
SiJP
Asked:
SiJP
1 Solution
 
bruintjeCommented:
Hello SiJP,

you could use something along the lines of
----------
   XPathDocument xmlInput = new XPathDocument(new StringReader(XML));
   XslTransform xsltProcessor = new XslTransform();
   xsltProcessor.Load(new XmlReader(new StringReader(XSL)));
 // parse the XML input and to load the XSLT stylesheet, then transform to a StringWriter
   StringWriter stringWriter = new StringWriter();
   xsltProcessor.Transform(xmlInput, null, stringWriter, null);

   // the stringwriter contains the resulting xml > stringWriter.ToString();
----------

hope this helps a bit
bruintje
0
 
SiJPAuthor Commented:
Apologies all - bruintje's aswer was great! - I've accepted this now

Si
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now