tags:

views:

38

answers:

1

Hai how to add a tag in a start and tag in end tag textwriter? Thanx

+1  A: 

Use an XmlWriter. Write your starting root element. Then pass the XmlWriter to the XSL transform. It will continue writing. When that's done, write your end root element:

public static void WrapTransform(
    Stream outputStream, 
    string styleSheetUri, 
    string documentUri)
{
    var transform = new XslCompiledTransform();
    using (var styleSheetReader = XmlReader.Create(styleSheetUri))
    {
        transform.Load(styleSheetReader);
    }

    using (var wrapper = XmlWriter.Create(outputStream))
    {
        wrapper.WriteStartElement("Root");
        transform.Transform(documentUri, wrapper);
        wrapper.WriteEndElement();
    }
}
John Saunders
Hai John,thanks for your answer.This is what i have now.So How to get a XmlDocument out of this xmlwriter? XmlWriter xmlwriter=XmlWriter.Create(stream1); xmlwriter.WriteStartElement("Root"); xslTrans.Transform(xPathDoc1, null, xmlwriter); xmlwriter.WriteEndElement();Thanks
Kaja
Hai i solved the problem.Thanks for the answer given by John Saunders
Kaja
Great. How did you solve it?
John Saunders
Hai John, i solved with ur answer..thts the 1 needed 4 me..thnx.
Kaja