如何读取XML字符串转换成XmlTextReader的类型 [英] How to read a xml string into XMLTextReader type

查看:484
本文介绍了如何读取XML字符串转换成XmlTextReader的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML字符串。我需要这个字符串转换成的XmlTextReader (System.Xml.XMLTextReader)输入DOTNET。

I have an XML string. I need to convert this string into XMLTextReader(System.Xml.XMLTextReader) type in dotnet.

我用下面的代码:

string szInputXml = "<TestDataXml><DataName>testing</DataName></TestDataXml>" ;
XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(szInputXml));



但在阅读里面的字符串是执行后空。

But the string inside the reader is empty after execution.

请帮我找出需要做去与给定的字符串来填充XmlTextReader的东西。

Please help me to figure out what needs to be done to get the XMLTextReader to be populated with the given string.

推荐答案

你如何确定如果字符串是空的?

How do you determine if the string is empty?

string szInputXml = "<TestDataXml><DataName>testing</DataName></TestDataXml>";
XmlTextReader reader = new XmlTextReader( new System.IO.StringReader( szInputXml ) );
reader.Read();
string inner = reader.ReadInnerXml();



没有3号线内是空的确实。现在,它包含了测试。

Without 3rd line "inner" was empty indeed. Now it contains testing.

这篇关于如何读取XML字符串转换成XmlTextReader的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆