LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I access the XML document in memory?

I've created an XML document referenced by the handle "doc". I would like to access the pointer to this XML doc so that it can be transmitted to a host computer.
The only way I have found to do this is to use CVIXMLSaveDocument() to save "doc" to a file, and then immediately read it back into a string. Is there a way I can access "doc" as a char[ ] directly in memory without doing all the file i/o procewssing?

    CVIXMLDocument doc = 0;
       ....
    CVIXMLNewDocument("event", &doc);
    CVIXMLGetRootElement(doc, &elem1);
      ....
    CVIXMLSaveDocument(doc, 1, XML_FILE_PATH); 


   


0 Kudos
Message 1 of 3
(3,609 Views)

While the CVIXML API does not provide a function for this, the underlying MSXML API lets one do this. Try the following code which loads a XML document and gets the XML as string. This should also work with XML that you programmatically create without saving to disk - just get the MSXML document handle and call MSXML_IXMLDOMDocumentGetxml.

#include <cvixml.h>

void main(void)
{
 char *xml;
 MSXMLObj_IXMLDOMDocument hDoc;
 CVIXMLDocument doc;
 
 
CVIXMLLoadDocument("c:\\temp\\test.xml", &doc);
 CVIXMLGetDocumentActiveXHandle(doc, &hDoc);
 MSXML_IXMLDOMDocumentGetxml(hDoc, 0, &xml);

}

Message 2 of 3
(3,587 Views)

Thanks, Mohan.

That was what I was looking for.

Doug

0 Kudos
Message 3 of 3
(3,578 Views)