How to remove attribute via Managed Code for '#PCDATA' is in nil content ?

D

digitor

Does anyone know how to do the following via c# managed code? I wish to
remove the attribute in the similar way in c# because I get the error:
'#PCDATA' is in nil content.



// Receive a reference to the element to be filled.
var objDataElement =
XDocument.DOM.selectSingleNode("/my:myFields/my:field1");

//Determine whether the xsi:nil attribute is set for this
//element. If so, remove the xsi:nil attributes so that
//the value can be set.
if (objDataElement.getAttribute("xsi:nil"))
objDataElement.removeAttribute("xsi:nil");

//Set the value of the element.
objDataElement.text = "10.0";

Microsoft have the following script example here:
http://support.microsoft.com/?id=826998
 
D

digitor

ok looks like I have solved this one myself.

simply do:

IXMLDOMNode xmlDOMPrice =
thisXDocument.DOM.selectSingleNode("/my:Company/my:CostsGroup/my:price");
xmlDOMPrice.attributes.removeNamedItem("xsi:nil");

easy!
 

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