06-17-2016 03:12 PM
I am serializing and deserializing some XML configuration files for a VI I am building. I would like for the XML output from the `Write to XML File' VI to be properly formatted for human consumption, i.e. with proper indentation. Is there a way to achieve this inside of LabVIEW?
06-17-2016 04:25 PM
06-17-2016 04:32 PM
Yes, when parsing XML using the custom parser there is an Invoke Node for an Element and a Node that has the `Get XML (Pretty Print)' method, but I haven't found any way of using this on the seralization end of things with the LabVIEW Schema. I am perfectly OK using the LabVIEW Schema for everything I need, but `Flatten To XML' VI in that set outputs XML strings and the rest of the VIs in the set seem to likewise operate exlusively on strings, not Node or Element refnums.
06-20-2016 07:33 AM
Save in a file and open using XML Notepad
@stevekuznetsov wrote:Yes, when parsing XML using the custom parser there is an Invoke Node for an Element and a Node that has the `Get XML (Pretty Print)' method, but I haven't found any way of using this on the seralization end of things with the LabVIEW Schema. I am perfectly OK using the LabVIEW Schema for everything I need, but `Flatten To XML' VI in that set outputs XML strings and the rest of the VIs in the set seem to likewise operate exlusively on strings, not Node or Element refnums.
06-20-2016 08:14 AM - edited 06-20-2016 08:36 AM
It seems pretty terrible in terms of UX for LabVIEW, but yes, what I am doing now is simply creating a temporary file using the `Generate Temporary File Path' VI, writing my data to that file, reading it back out, pretty-printing it, writing it to the ``correct'' destination. then deleting the temporary file. I really hope there is a simpler way of doing this...
This is better than nothing, I guess, but has the annoying effect that the pretty-printed XML closing tags are not indented correctly with their starting tags, like so:
<LVData>
<Version>13.0f2</Version>
<Cluster>
<Name>My Named Cluster</Name>
<NumElts>4</NumElts>
<DBL>
<Name>Some Double Value</Name>
<Val>0.00000000000000</Val>
</DBL>
<DBL>
<Name>Another Double Value</Name>
<Val>0.00000000000000</Val>
</DBL>
<DBL>
<Name>Yet Another Double Value</Name>
<Val>0.00000000000000</Val>
</DBL>
<String>
<Name>String Value</Name>
<Val>1.0.0</Val>
</String>
</Cluster>
</LVData>