G
G. Kumar
I have an XML file that I'm trying to read and write to in an infopath form. The data connection that I use says "Recieve Data", however with JScript, using the "save" method of the IXMLDOMDocument object, you can write to the url of the XML file data connection. I am trying to switch my code to C#, however I can't get it to work. In JScript, I did:
var dbxml = XDocument.DataObjects("Database").DOM.xml;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.loadXML(dbxml);
.... modify xmlDoc ...
xmlDoc.save(XDocument.DataObjects("Database").QueryAdapter.FileURL);
Now, my idea for C# was this:
string dbxml = eventObj.XDocument.DataObjects["Database"].DOM.xml;
IXMLDOMDocument xmlDoc = new IXMLDOMDocument();
xmlDoc.loadXML(dbxml);
.... modify xmlDoc ...
object dbxmlfile = eventObj.XDocument.DataObjects["Database"].QueryAdapter;
xmlDoc.save(((XMLFileAdapter) dbxmlfile).FileURL);
I am not able to do the command "new IXMLDOMDocument()" which is not surprising because I totally guessed at how to create a new IXMLDOMDocument. Does anyone else know this or know how to write to XML files using C#? Any help or sample code would be very appreciated. Thanks!
var dbxml = XDocument.DataObjects("Database").DOM.xml;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.loadXML(dbxml);
.... modify xmlDoc ...
xmlDoc.save(XDocument.DataObjects("Database").QueryAdapter.FileURL);
Now, my idea for C# was this:
string dbxml = eventObj.XDocument.DataObjects["Database"].DOM.xml;
IXMLDOMDocument xmlDoc = new IXMLDOMDocument();
xmlDoc.loadXML(dbxml);
.... modify xmlDoc ...
object dbxmlfile = eventObj.XDocument.DataObjects["Database"].QueryAdapter;
xmlDoc.save(((XMLFileAdapter) dbxmlfile).FileURL);
I am not able to do the command "new IXMLDOMDocument()" which is not surprising because I totally guessed at how to create a new IXMLDOMDocument. Does anyone else know this or know how to write to XML files using C#? Any help or sample code would be very appreciated. Thanks!