xmlDocument如何判断一个节点的某个属性是否存在
XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.LoadXml(strXML);
XmlNodeList oNodes = oXmlDoc.SelectNodes( "Menu/Department/menuItem ");
... ...
Response.Write( " <br> " + oNodes[i].Attributes[ "menuName "].InnerText);
如果menuName不存在,运行时会报错,我如何加一个是否存在的判断?
------解决方案--------------------if(oNodes[i].Attributes[ "menuName "] != null)
Response.Write( " <br> " + oNodes[i].Attributes[ "menuName "].InnerText);