How to pass and get the string based xml data in xslt transform using C#? -
i want convert 1 xml file xml file using xslt.here, can able pass input document xpathdocument , save output file in disk passing outfile xmltextwriter.
but problem is... have input in string format , want output string.instead of passing location of input file, want pass string contains xml data.
so have pass string object xpathdoccument in someway , resultant xml file string.instead of save output file,i want output string.
xpathdocument xpathdoc = new xpathdocument("c:\\inputxml.xml"); xslcompiledtransform xslt = new xslcompiledtransform(); string xsltfile = "c:\\conversion.xslt"; xslt.load(xsltfile); string outputfile = "c:\\myhtml.html"; xmltextwriter writer = new xmltextwriter(outputfile, null); xslt.transform(xpathdoc, null, writer); writer.close(); please guide me out of issue...
xpathdocument accepts textreader. can give stream new xpathdocument(new stringreader(xmlstring)). xmltextwriter accepts textwriter. can pass stringwriter.
--edit--
var sw = new stringwriter(); xmltextwriter writer = new xmltextwriter(sw); xslt.transform(xpathdoc, null, writer); var str= sw.tostring();
Comments
Post a Comment