如何从ASP.NET中的XML标记本身访问数据 [英] How to acces data from within the XML tag itself in ASP.NET
本文介绍了如何从ASP.NET中的XML标记本身访问数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在.net框架中访问排名数据
在这种情况下我想要访问排名第1的价值
how can i access the rank data in .net framework
in this case i want to access the value 1 of rank
<clinical_study rank="1">
</clinical_study>
我尝试了什么:
i尝试应用xmlnodes但无法找到保留数据的方法..
What I have tried:
i have tried applying xmlnodes but couldnt find a way to retain the data..
推荐答案
Rank 是节点 clinical_study 的属性,您可以使用XmlDocument类或XMLReader读取xml并获取其属性值
见下面的代码片段
Rank is the attribute of node clinical_study, you can either use XmlDocument class or XMLReader to read xml and get its attribute value
see below snippet
var doc = new XmlDocument();
//doc.Load(path);
string xml = "<root><clinical_study rank="1"></clinical_study></root>"
doc.LoadXml(xml);
string szRank = doc.getElementByTagName("clinical_study")[0].Attributes["rank"].value;
希望有帮助
hope it helps
这篇关于如何从ASP.NET中的XML标记本身访问数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文