LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

XML doc to string fails when string length is greater than 512 bytes.

Solved!
Go to solution

I have been using the following code to write a XML string.  If the resultant string is less than ~512 bytes, the string will be created, if >~512 bytes, the routine does not create the string.  Assuming the doc contains a XML document:

 

 CVIXMLDocument           doc = 0;
 MSXMLObj_IXMLDOMDocument hDoc = 0;

...

cvistatus = CVIXMLSaveDocument ( doc, 0, "Test1.xml" );            
status = CVIXMLGetDocumentActiveXHandle(doc, &hDoc);                 

hRlt = MSXML_IXMLDOMDocumentGetxml (hDoc, &errInfo, &strXml);       

The SaveDocument routine always works, the XML file contains the XML document regardless of size.

The Getxml routine only creates the XML string in strXml when the string length is less than ~512 bytes.

 

Does anyone have a clue to the problem ?

0 Kudos
Message 1 of 8
(3,774 Views)

Hi mike7,

 

It appears the call MSXML_IXMLDOMDocumentGetxml is calling into the Microsoft MSXML DOM library. I tried digging around their documentation to see if there was any information on this particular method, but their C library information is somewhat limited. It is possible that 512 bytes could be the limitation of the read size, or the default value. It is posisble the function has an optional parameter to change the default size, but the documentation, again, is rather sparse. It does look like the XML DOM library has been updated or changed, so it may be the new methods will perform better. Here is the current documentation I found from Microsofts website.

 

http://msdn.microsoft.com/en-us/library/ms764730%28v=vs.85%29.aspx

 

If you have any further information I may be missing I would love to see it, but this looks like a limitation with Microsoft's library. Are you using MSXML 6? That appears to be the most up to date version.

 

Regards,

James W.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(3,751 Views)

Are you sure strXml does not have the correct value when MSXML_IXMLDOMDocumentGetxml returns? Try puts(strXml) after this call and see what gets printed to the standard output window. If it does not have the expected value, what are the values of hRlt and errInfo's fields? This will indicate what error happened.

0 Kudos
Message 3 of 8
(3,739 Views)

James

 

Thanks for answering my message.  My original attempt at creating a XML string was with the MSXML v2.0 library; I have tried that same steps using MSXML v.6.0 with the same results.  There seems to be a limitation on the resultant string of ~512 bytes within the Getxml routine.  I have not found any documentation at Microsoft relating to a buffer size or limit.  At this point, I am coding a work around, i.e. a kluge.

 

Thanks,

 

mike7

0 Kudos
Message 4 of 8
(3,726 Views)

Mohan

 

Thanks for answering my message.  Yes, I am sure that string strXml does not contain the document.  The odd thing is that the return code is 0, and the errorinfo fields remain used.  It appears Getxml  has completed successfully.

 

Thanks,

mike7

0 Kudos
Message 5 of 8
(3,722 Views)
Solution
Accepted by topic author mike7

Because the string is very long, the CVI debugger may not be displaying it. This is why I am wondering if you tried to print it using puts or printf. Given that the return value is 0 and the ERRORINFO is also indicating success, I would double-check the string by printing it to console or file.

0 Kudos
Message 6 of 8
(3,718 Views)

The XML string when failing is only 750 bytes, but I will check it out.

 

Thanks,

mike7

0 Kudos
Message 7 of 8
(3,709 Views)

You are correct, the debugger is not displaying the XML string.  But the string has been correctly created.

Thanks,

 

mike7

0 Kudos
Message 8 of 8
(3,688 Views)