How can I copy a block of XML from one document to the other?

前端 未结 3 1246
耶瑟儿~
耶瑟儿~ 2021-01-16 04:54

I have two dataGridViews that load up an XML file each, I have made it so that you can drag and drop rows in between each of the grids. However at the moment, all that it do

3条回答
  •  暖寄归人
    2021-01-16 05:15

    Every XmlNode has several methods (and XmlDocument is a child class of XmlNode), so you can use xDoc.SelectNodes() or xDoc.SelectSingleNode() to pick a specific node wherever in the document structure, store that node in an object (let's call it needleNode), and then do xDoc.InsertBefore(Copy, ref needleNode) or xDoc.InsertAfter(Copy, ref needleNode). Using these four functions you can insert the xml section to absolutely ANY part in the structure of the second xml.

提交回复
热议问题