osu*_*sum 19 c# xml string xmltextreader
我有一个XML字符串.我需要将此字符串转换为dotnet中的XMLTextReader(System.Xml.XMLTextReader)类型.
我使用了以下代码:
string szInputXml = "<TestDataXml><DataName>testing</DataName></TestDataXml>" ;
XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(szInputXml));
Run Code Online (Sandbox Code Playgroud)
但执行后读取器内的字符串为空.
请帮我弄清楚需要做什么才能用给定的字符串填充XMLTextReader.
dze*_*ras 39
你如何确定字符串是否为空?
string szInputXml = "<TestDataXml><DataName>testing</DataName></TestDataXml>";
XmlTextReader reader = new XmlTextReader( new System.IO.StringReader( szInputXml ) );
reader.Read();
string inner = reader.ReadInnerXml();
Run Code Online (Sandbox Code Playgroud)
没有第三行,"内在"确实是空的.现在它包含测试.
| 归档时间: |
|
| 查看次数: |
58681 次 |
| 最近记录: |