NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

XML data and "invalid characters"

Hello everyone,
 
I'm developing a custom XML report for TestStand and I'm a bit confused about how to handle certain characters. For example, lets say I have a test step titled "Check that current is < 50mA". Now, when this data is written into the XML report it can be found between the Step Name tags, like this
 
<Step Name>Check that current is <50mA</Step Name>
 
Now the character causing the problem is "<" as XML presumes it indicates a new tag. Looking through XML resources it seems one way to escape these characters is to use the CDATA tags like this:
 
<Step Name><![CDATA[Check that current is <50mA]]></Step Name>
 
or to specify in the .xsl file "disable-output-escaping="yes" in the for these affected fields, like step name. However I'm concerned that by using the "disable-output-escaping" method I will encounter problems when feeding the XML file into a parser.
 
Now I'm a bit curious about how different parsers act with the CDATA tag, if I parse the step name fields will I get "Check that current is <50mA" or will I get ><![CDATA[Check that.....]]>. Any ideas?
 
Currently I'm using a function from the modelsupport.dll to replace these invalid characters with entity references, for example "<" is replaced with &lt; but this is not a good solution from the parser point of view.
 
Best regards and thanks in advance for any advice,
Aleksi
0 Kudos
Message 1 of 5
(5,497 Views)

Hi,

>>>

Now I'm a bit curious about how different parsers act with the CDATA tag, if I parse the step name fields will I get "Check that current is <50mA" or will I get ><![CDATA[Check that.....]]>. Any ideas?
>>>
 
Is it easy just to try it and see what happens?
 
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 5
(5,496 Views)
Hi Ray,

I've tried importing XML data with CDATA tags into MS Excel and atleast that works OK (meaning that the CDATA tags are omitted when it looks up the data).

But I guess I'm looking for an answer on a general level, from people who have used various parsers and XML. Is the CDATA something that is "embedded" into XML and all XML parsers understand the tag?

BR,
Aleksi
0 Kudos
Message 3 of 5
(5,491 Views)
CDATA is part of the XML standard and is something that most parsers should know how to deal with.

http://www.w3schools.com/xml/xml_cdata.asp

Allen P.
NI
0 Kudos
Message 4 of 5
(5,477 Views)

Hi Allen,

I actually read the w3schools' information about CDATA earlier when searching the web for information. But, I just realised I had understood it wrong when I read it the first time. From the link above:

Only text inside a CDATA section will be ignored by the parser.

I thought the CDATA tag would cause the parser to omit actual data, but the sentence actually means that the data inside the CDATA tag is handled by the parser as normal text and not as a XML tag (which makes perfect sense now...)

Thanks,

Aleksi

0 Kudos
Message 5 of 5
(5,473 Views)