本文介绍了从字符串输入中读取xml元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是dinakar
Iam具有将xmldata作为输入数据的函数,并且我已从该xmlstring输入中提取元素值

this is dinakar
Iam having a function which has xmldata as input data and i have extract element values from that xmlstring input

string function1()
{
<car>maruthi</car>
<bike>....</bike>
.
.
.
return xml.innertext.tostring()
}
function2(string xmldata)//its input is from previous functio1 strinxml output
{
/// need code to read xml element from sting xmldata
}


请帮助我,请


please help me out please

推荐答案

XmlDocument xml = new XmlDocument();
            xml.LoadXml("<test><node1>testnode</node1></test>");
            XmlNodeList nodes = xml.GetElementsByTagName("node1");
            string value = nodes[0].InnerText;//this one returns testnode



进一步了解 System.Xml命名空间 [ ^ ].



Read more about System.Xml Namespace[^].



这篇关于从字符串输入中读取xml元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 23:20
查看更多