about String convert XmlReader

D

dongxm

XslTransform xslt = new XslTransform();
xslt.Load(myXmlReader)

the myXmlReader is a XmlReader,but i have String of xsl file's content...
how to do,String convert XmlReader?

thanks
 
D

Daniel O'Connell [C# MVP]

dongxm said:
XslTransform xslt = new XslTransform();
xslt.Load(myXmlReader)

the myXmlReader is a XmlReader,but i have String of xsl file's content...
how to do,String convert XmlReader?
Its a bit of a pain. Basically you need to create a StringReader and create
the XmlReader around that

StringReader sr = new StringReader(<string>);
XmlReader myXmlReader = new XmlTextReader(sr);

You may also have to use XML encoded to unicode instead of UTF8 since I
believe StringReader always returns unicode bytes(which means the encoding
attribute has to be properly set).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top