当前位置: 代码迷 >> ASP.NET >> 请教读xml节点属性有关问题
  详细解决方案

请教读xml节点属性有关问题

热度:5699   发布时间:2013-02-25 00:00:00.0
请问读xml节点属性问题
为什么我在读取xml时节点没有setattribute和getattribute的属性,
只有根节点有呢?纳闷

------解决方案--------------------------------------------------------
直接这样取,或者赋值
string text = XmlNode.Attribute[ "name "].Value;
XmlNode.Attribute[ "name "].Value = "new value ";
------解决方案--------------------------------------------------------
((XmlElement)XmlDoc.SelectNodes( "EVI/FlatExcelSchema/Item ")[0]).GetAttribute( "topCell ");

供参考


------解决方案--------------------------------------------------------
if (oNode.Attributes.GetNamedItem( "readonly ") != null)
{
_TrReadOnly = oNode.Attributes.GetNamedItem( "readonly ").Value.ToString();
}
------解决方案--------------------------------------------------------
如果没有属性,先创建一个再加到节点上
XmlAttribute xmlAtt= xmlDoc.CreateAttribute( "name ");
xmlAtt.Value = " ";
xmlnode.Attributes.Append(xmlAtt);
  相关解决方案