Trying to use RemoveChild() on XmlNodeList messes up my XmlNode collection
- by user299090
Hi there,
I'm trying to remove a specific node from a XmlNodeList named listaWidths. This specific list has 5 items before I use RemoveChild(). But, after the RemoveChild() statement, the list stays only with 1 item.
XmlNodeList listaWidths = xmlDoc.SelectNodes("/MsBuild:Report/MsBuild:Body/MsBuild:ReportItems/MsBuild:Tablix/MsBuild:TablixBody/MsBuild:TablixColumns/*", nsmgr);
int indexEpoca = 0;
//Remover época
XmlNode node = listaWidths[indexEpoca];
XmlNode parent = listaWidths[indexEpoca].ParentNode;
parent.RemoveChild(node);
This is a RDL Reporting Services XML.
The specific XML code is here:
<Tablix Name="Tablix3">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>1.602in</Width>
</TablixColumn>
<TablixColumn>
<Width>1.61in</Width>
</TablixColumn>
<TablixColumn>
<Width>1.6323in</Width>
</TablixColumn>
<TablixColumn>
<Width>1.6023in</Width>
</TablixColumn>
<TablixColumn>
<Width>1.6033in</Width>
</TablixColumn>
</TablixColumns>
(...)
I've tried every combination possible, with no luck whatsoever. What am I doing wrong?
Thank you.