I
a document with several StructuredDocumentTags I want to remove all but one, at
for that specific one I want to remove the SDT, but keep the content.
When
Remove() or RemoveSelfOnly() executed, the for each loop exit, hence only the
first SDT is handled.
var doc = new Document(fileName);
string tagName = "A";
foreach(var item in doc.GetChildNodes(NodeType.StructuredDocumentTag, true, true))
{
var sdt = (StructuredDocumentTag)item;
if (sdt.Tag.Equals(tagName))
sdt.RemoveSelfOnly();
else
sdt.Remove();
}
What is wrong with the code?