LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Set Encoding for XML Document?

I'm trying to create a new XML Document using CVI 8.1.0 (or CVI 8.0.1) and the CVIXML instrument driver.  I would like set the encoding to UTF-8 for the document so the first line is <?xml version="1.0" encoding="UTF-8"?>.  How do I do this?  I am able to get <?xml version="1.0"?> only.
0 Kudos
Message 1 of 5
(4,429 Views)
Hi ogre,

At first glance it doesn't look like this functionality is provided by the CVIXML instrument driver, but I will look into this further.

Regards,
0 Kudos
Message 2 of 5
(4,387 Views)

Hi ogre,

To set the encoding scheme for an XML document, you can use the
createProcessingInstruction. Our CVIXML instrument driver (which is basically and user-friendly wrapper made around the MSXML interface) uses this method to specify the version of the XML document. So, what you could do is simply modify our existing CVIXML instrument driver to include the encoding. It's actually quite simple to do this.

First off, open up the cvixml.c file located in the
<CVI>\toolslib\toolbox directory in CVI. Then change the value of the constant XML_PROC_INSTR_DATA (located on line 42) from "version=\"1.0\"" to "version=\"1.0\" encoding=\"UTF-8\"". The save your source file and select Options >> Create Object file. This object file (cvixml.obj) is attached to your cvixml.fp function panel. 

To test this out, you could simply use some code like

CVIXMLNewDocument ("RootElement", &xmlDoc);
CVIXMLSaveDocument (xmlDoc, 0, "C:\\Test.xml");


Then the Test.xml document should say

<?xml version="1.0" encoding="UTF-8"?>
<RootElement/>


Hope this helps!

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 3 of 5
(4,370 Views)

I create XML Documents (testreports) using CVI 2009 and the CVIXML instrument driver.

I got almost the same problem... the only thing i need, is to add a schema (.xsl) into the XML document over the LabWindows CVIXML-Functions...

is this possible?

0 Kudos
Message 4 of 5
(3,761 Views)

Hello ps_wag,

 

Have a look at this link. Let me know if this helps you.

 

Regards,

0 Kudos
Message 5 of 5
(3,745 Views)