0

Ihave an issue with reading an XML string into XMLTextReader..

I'm querying the a DB and getting a DataSet back. From that DataSet, I'm reading a specific row and column (which contains XML strings) and using that XML string value to pass to an XMLTextReader. The problem is that I'm getting the error "Illegal Character in path".

I know that the XML string returned from the DB is proper, as I can open the XML in my browser.

This is the code I'm using:

string XMLstring = DS.Tables[0].Rows[i][y].ToString();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(XMLstring);

StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
xmlDoc.WriteTo(xw);
XmlTextReader textReader = new XmlTextReader(sw.ToString());

Any ideas why I'm getting this error??

Thanks!

4

1 に答える 1

0

XMLTextReader コンストラクターのオーバーロードを見てください。XML 文字列を読み込もうとしていますが、文字列のオーバーロードにはパスが必要です。

XML 文字列をファイルに書き込んで、XMLTextReader にそのファイルのパスを指定してみてください。

于 2011-08-19T18:02:21.773 に答える