写了一个函数,返回值是STRING类型:str
str的内容如下:<DMResponse><Code>1</Code><Description>Your request was successfully received and processed.</Description><ResultData><Explanation> Here is the response to your request </Explanation>
<GetListNamesRs><ListName>DMCList01</ListName><ListName>LIST02</ListName></GetListNamesRs></ResultData></DMResponse>
实际上就是一个XML文档,现在的问题是:如何得到2个<ListName></ListName>标记里的值,并把它显示出来。
问题比较急,谢谢!!!
困惑是:返回来的是一个string类型,能不能把它当作xml文档来读?怎么读呀?比较郁闷。
谢谢高手解答
str的内容如下:<DMResponse><Code>1</Code><Description>Your request was successfully received and processed.</Description><ResultData><Explanation> Here is the response to your request </Explanation>
<GetListNamesRs><ListName>DMCList01</ListName><ListName>LIST02</ListName></GetListNamesRs></ResultData></DMResponse>
实际上就是一个XML文档,现在的问题是:如何得到2个<ListName></ListName>标记里的值,并把它显示出来。
问题比较急,谢谢!!!
困惑是:返回来的是一个string类型,能不能把它当作xml文档来读?怎么读呀?比较郁闷。
谢谢高手解答
XmlDocument doc=new XmlDocument();
doc.LoadXml(str);
然后用xmlpath来读取吧
doc.LoadXml(str);
XmlNodeList xnl= doc.getNodeByTagName("ListName");
string str = xnl[0].childNode.item(0).innerText
doc.LoadXml(str);
XmlNodeList xnl= doc.selectsinglenode("//ListName");
for each (XmlElement eme in xnl)
{
xxxxxx=eme.innertext;
}