English 中文(简体)
• 在Xml NodeList messess使用RemoveChild()
原标题:Trying to use RemoveChild() on XmlNodeList messes up my XmlNode collection

我试图从一个名为“名单”的XmlNodeList中删除一个具体节点。 这一具体清单在我使用“消除儿童”之前有5个项目。 但是,在“消除儿童”发言之后,名单仅剩下1个项目。

XmlNodeList listaWidths = xmlDoc.SelectNodes("/MsBuild:Report/MsBuild:Body/MsBuild:ReportItems/MsBuild:Tablix/MsBuild:TablixBody/MsBuild:TablixColumns/*", nsmgr);                
int indexEpoca = 0;
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.

最佳回答

http://msdn.microsoft.com/en-us/library/hcebdtae.aspx” rel=“nofollow noreferer”> 《第号选择文件》明确指出:“用这种方法归还的XmlNodeList物体在基本文件保持不变时仍然有效。 如果基本文件发生变化,则可能退还意外结果(无例外)。

因此,在你操纵该文件之后,你从别克斯岛返回的XmlNodeList的经验可能不是你所期望的,而是符合文件。 如果你操纵该文件,你将不得不再次呼吁挑选新会员。

我认为,OMD执行工作的设计者。 NET框架犯了错误,将XmlNodeList作为一种抽象的类别,用于具体实施,其行为差别很大。 如果使用,例如 然后,根据W3C DOM的规格要求,孩子们获得一个“终身”的 no子,在这种情况下,证件的变更自动改变(如果需要的话)。 然而,正如你所经历的那样,选择不再回到一个有相当不同行为的节点。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签