LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Properly Format XML Output From LabVIEW for Human Eyes

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?

0 Kudos
Message 1 of 5
(4,461 Views)
I don't remember where it is at right off hand, but there is a pretty print property that shows it all properly indented.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(4,452 Views)

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.

Message 3 of 5
(4,450 Views)

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.


 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 5
(4,391 Views)

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...  

 

xml.PNG

 

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>

0 Kudos
Message 5 of 5
(4,379 Views)