Trying to use RemoveChild() on XmlNodeList messes up my XmlNode collection
Posted
by user299090
on Stack Overflow
See other posts from Stack Overflow
or by user299090
Published on 2010-03-22T23:59:16Z
Indexed on
2010/03/23
0:01 UTC
Read the original article
Hit count: 245
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.
© Stack Overflow or respective owner