Simple XML to XML Transformation

Posted on 2006-05-05
Last Modified: 2010-04-23 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: ""
 - 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.

Question by:SiJP
    LVL 44

    Accepted Solution

    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
    LVL 3

    Author Comment

    Apologies all - bruintje's aswer was great! - I've accepted this now


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now