获取标签名称和值 [英] Get Tag name and value

查看:78
本文介绍了获取标签名称和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Hi,

var formresult = (divelement.Descendants("form")).ToArray();



我正在迭代表单标签,并获得以下结果.



I am iterating form tag where I am getting the below result.

<form>
  <cc1:groupname xmlns:cc1="url">ABC</cc1:groupname>
</form>


我正在使用var并使用foreach循环迭代var元素.

现在我想检查表单标签,我要检查组名标签,如果在那里,那么我想获取值,即ABC
但问题是我无法直接检查"cc1:groupname"值.

我该怎么办?

谢谢
sjs4u


I am using var and iterate var element using foreach loop.

Now I want to check form tag where I want to check groupname tag and if it is there then I want to get value i.e. ABC
but the problem is I cannot direct check "cc1:groupname" value.

How can I do this?

Thanks
sjs4u

推荐答案

您可以获取任何您知道TagName的节点.即"cc1:groupname"
以下是获取值的代码.我认为这会有所帮助.

You can get any node fi you know the TagName. i.e."cc1:groupname"
following is the code to get the value. I think it will help.

//here doc is xmlDocument 
XmlNodeList NodesCollection = doc.GetElementsByTagName("cc1:groupname");

foreach (XmlNode _node in NodesCollection )
{
   //You can the value with following property (_node.innertext)
     string value = _node.innertext ;
}


这篇关于获取标签名称和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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