Removing Fields from Section using C#

B

Boris Kleynbok

I am using C# in Form.cs

Having trouble traversing the IXMLDOM

All in all I need to programmatically remove all the repeating sections
fields.

Kind of restoring section to its original state.

This section could be already repeated and a button on the section should
remove the fields.

try
{
IXMLDOMNodeList nodeList =
thisXDocument.DOM.selectNodes("/mstns:SHORT_SEARCH/mstns:INSTRUMENT");
foreach(IXMLDOMNode node in nodeList )
{
if ( node.selectSingleNode("mstns:INST_NAME").text !="" )
{



//REMOVE DEED
//REMOVE MORTGAGE

// node.removeChild(node.selectSingleNode("mstns:INST_NAME");
/*

//REMOVE ASSIGNEMENT

if (node.selectSingleNode("mstns:ASSIGNEMENT").text !="")
{
node.removeChild(node.selectSingleNode("mstns:ASSIGNEMENT"));
}


//REMOVE AGREEMENT

if (node.selectSingleNode("mstns:AGREEMENT").text !="")
{
node.removeChild(node.selectSingleNode("mstns:AGREEMENT"));
}

//REMOVE BINDED INST

if (node.selectSingleNode("mstns:BINDED_INST").text !="")
{
node.removeChild(node.selectSingleNode("mstns:BINDED_INST"));
}

*/

}

}
}
catch(Exception ex)
{
thisXDocument.UI.Alert(ex.Message );

}


Will be much ablidged.
 
F

Franck Dauché

Hi Boris,

Are you saying that you code that you posted didn't work? Can you tell us
more about you need exactly.
Because, indeed to remove child from a repeating group in C#, you can use:
IXMLDOMNodeList oNodes =
thisXDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2");
foreach (IXMLDOMNode oNode in oNodes)
{
oNode.parentNode.removeChild(oNode);
}


Regards,

Franck Dauché
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top