日期:2014-05-17  浏览次数:20826 次

一个关于xml节点处理的问题
愚生在做项目时遇到了在解析xml节点时,发现的节点名称相同,我想提取两个"Delta"里的数据,如何操作~愚生的代码如下:
if (!string.IsNullOrEmpty(msgAlarm.MateMetaData.Xmlmessage))
                {
                  
                    xml.LoadXml(msgAlarm.MateMetaData.Xmlmessage);
                   
                    if (msgAlarm.MateMetaData.Messagetype.IndexOf("CountingEventMsg") != -1)
                    {
                        xml.SelectNodes()
                        if (msgAlarm.MateMetaData.Messagetype.IndexOf("CounterIn") != -1)
                        {
                           xmlNodeList = xml.GetElementsByTagName("Delta");
                           if (xmlNodeList != null && xmlNodeList.Count > 0)
                           {
                               cnt1 = xmlNodeList[0].InnerText.Trim();
                           }
                        }
                        if (msgAlarm.MateMetaData.Messagetype.IndexOf("CounterOut") != -1)
                        {
                            xmlNodeList = xml.GetElementsByTagName("Delta");
                            if (xmlNodeList != null && xmlNodeList.Count > 0)
                            {
                     &