2 つのノードを返す linq to xml クエリがあります。これらのノードを繰り返し処理して、それらのコンテンツを置き換えようとしています。ただし、XDocument に追加されているコンテンツには、クエリ基準に一致するノードが含まれています。
protected internal virtual void AddLinkDocument(XDocument content, TaskRequest request)
{
var links = content.Descendants("some.link").Where(tag => tag.Attribute("document-href") != null);
foreach (XElement link in links) //first time through there are 2 links found
{
//do some stuff
link.ReplaceNodes(inlineContent); // after content is added, "links" now in foreach now has many new links found
}
}
コレクション、「リンク」が foreach を介して毎回動的に更新されるのはなぜですか?
助けてくれてありがとう!