c# - Transform XML returned from a web request using XLST -


i see several questions close none cover it:

i can cobble these worry passing through many steps efficient.

what have this, read xml http web request:

        webrequest request = webrequest.create(url);         webresponse response = request.getresponse();         stream stream = response.getresponsestream();         streamreader streamreader = new streamreader(stream);         string xml = streamreader.readtoend(); 

this before need apply xlst transform needed. have (possibly null) xslcompiledtransform object.

so want add block like:

if(transform != null) {   xml = transform.transform(xml); } 

clearly isn't possible written. see stringreaders , xmlreaders can created inefficient xml string , push object? can use stream or streamreader objects directly support same basic flow, optional transformation?

personally i'd use xmldocument.load() function load xml url, without using webrequest in case.

you can pass xmldocument straight xslcompiledtransform.transform() then.

xmldocument doc = new xmldocument(); doc.load(url); if (transform != null) {  xmldocument tempdoc = new xmldocument();  using (xmlwriter writer = tempdoc.createnavigator().appendchild())  {   transform.transform(doc, writer);  }  doc = tempdoc; } //use xmldocument transformed output 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -