11-12-2010 09:18 PM
I'm using the CVI XML functions. When I try to insert some pre-exsting HTML as the element value with CVIXMLSetElementValue, it dutifuly converts all the HTMLangle brackets into < and >, which is NOT what I want.
(I can protect the XML integrity by wrapping it in [CDATA[ ....]] but that does not solve the conversion issue here.)
Any suggestions?
Thanks,
Ian
Solved! Go to Solution.
11-15-2010 02:27 PM
To explain a bit further, below is a code snippet and the unwanted result that I see. Does this behavior - even with CDATA - make good design sense?
From my perspective CVIXMLSetElementValue should respect CDATA elements. Am I right? Or just biased?
stat = CVIXMLSetElementValue (test1_element, "Hello"); stat = CVIXMLSetElementValue (test2_element, "<p>Hello</p>"); stat = CVIXMLSetElementValue (test3_element, "<! [CDATA[<p>Hello</p>]] >"); // Problematic Output: // <?xml version="1.0"?> // <root> // <test1>Hello</test1> // <test2><p>Hello</p></test1> // <test3><! [CDATA[<p>Hello</p>]] ></test1> // </root>
11-16-2010 10:21 AM
The CVIXML code is just a wrapper over the Microsoft XML DOM (MSXML) ActiveX library. You can see the source code for this in <cvi>/toolslib/toolbox/cvixml.c. The behavior you are seeing is coming from MSXML. You may be able to find more information and possible workaround for this on Microsoft forums like MSDN.
11-17-2010 03:23 PM
Thanks, Mohan. I have opted to access this HTML by always reading from the XML using the MS XML library, so it will all work out in the end. It took a small wrapper program, and adds a step to my development workflow, but it gets me past it for now. But I might get ambitious and pursue your suggestion at a later date.
--Ian