LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems embedding HTML into XML with CVIXMLSetElementValue - unwanted &lt and &gt

Solved!
Go to solution

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 &lt and &gt, 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

0 Kudos
Message 1 of 4
(4,093 Views)

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>&lt;p&gt;Hello&lt;/p&gt;</test1>
// <test3>&lt;! [CDATA[&lt;p&gt;Hello&lt;/p&gt;]] &gt;</test1>
// </root>

 

0 Kudos
Message 2 of 4
(4,046 Views)
Solution
Accepted by topic author Ian.W

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.

0 Kudos
Message 3 of 4
(4,019 Views)

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

0 Kudos
Message 4 of 4
(3,990 Views)