replace xml element

Posted by snorlaks on Stack Overflow See other posts from Stack Overflow or by snorlaks
Published on 2010-06-07T21:55:20Z Indexed on 2010/06/07 22:02 UTC
Read the original article Hit count: 381

Filed under:

Hello,

Im doing something like that:

var results = from d in myDocument.Elements().Descendants("myName") select d;

foreach (var result in results){
   if (sth...){
      result.replace(myXElement);
   }
}

The problem is that when I replace an element I cant iterate to the next element cause there is null reference. (var result in results).

Is there any other way to replace that element with another one and still be able to iterate through that document ?

thanks for help

© Stack Overflow or respective owner

Related posts about linq-to-xml