foreach (System.Xml.XmlNode _Node in nodeList)
 {  
      XmlElement Xmlele=(XmlElement) _Node;
      Xmlele.SetAttribute("newDD_ID","TestDD_ID");                 
 } docWrite.Save(sourceFile);

解决方案 »

  1.   

    XmlElement xmlele;if(xmlele.HasAttributes)
    {
       foreach(XmlAttribute xmlatt in xmlele.Attributes)
       {
           Console.WriteLine(xmlatt.Value);
       }
    }
      

  2.   

    XPathNavigator navItem = iterator.Current.Clone();       //defines another Navigator to search the nodes inside            while (navItem.MoveToNextAttribute())
               {               
                if (navItem.Name=="title")  //scan the property of the caption if the caption exist then  do below
                {
                   bool DD_IDExist=false;   //default it doesn't exist
                   title=navItem.Value ;    //get teh node 's caption
                   XPathNavigator dd_idItem = iterator.Current.Clone();       //defines another Navigator to search the nodes inside
                   // TODO: below is not the best sulution,
    //               dd_idItem.MoveToFirstAttribute();           
    //               while (dd_idItem.MoveToNextAttribute())  
    //               {  
    //                  if (dd_idItem.Name=="DD-ID")   
    //                  {
    //                     DD_IDExist=true;
    //                     break;
    //                  }                           
    //               }
      

  3.   

    xpaht类型没发转换成xmelement类型的,请问应该怎么实现!