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.<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>
var doc = new Document(fileName);<o:p></o:p>
string tagName = “A”;<o:p></o:p>
foreach (var item in doc.GetChildNodes(NodeType.StructuredDocumentTag,
true, true))<o:p></o:p>
{<o:p></o:p>
var sdt = (StructuredDocumentTag)
item;<o:p></o:p>
if (sdt.Tag.Equals(tagName))<o:p></o:p>
sdt.RemoveSelfOnly();<o:p></o:p>
else<o:p></o:p>
sdt.Remove();<o:p></o:p>
}<o:p></o:p>
What is wrong with the code?