LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format XML data

Hi team , 

 

I wrote a data into XML file , but format was i need to change 

 

All data are written in a single line .  All parameters name and data need to write in separate new line 

 

How i need to modify and write. 

 

Please suggest 

 

Thanks in advance 

Download All
0 Kudos
Message 1 of 5
(2,286 Views)

There should be no need for linebreaks in XML, they are only there for better human(!) readability. Maybe, some odd software needs them, too.

 

However,  XML documents in LabVIEW have the method "pretty print", which returns the document as XML with linebreaks and indentation:

 

xml.png

 

Message 2 of 5
(2,243 Views)
0 Kudos
Message 3 of 5
(2,178 Views)

Hi sebastian weber,

 

I got the data for 1 set  . But i am in need to display data  for multiple tagname after a completion first tagname ( data set ) .

 

all data should be printed in a same document (multiple tagname ) .

 

i got a error . please find attachment of error and model format  

Download All
0 Kudos
Message 4 of 5
(2,091 Views)

Hi!

 

You have a SubVI which inserts the nodes, which I have not on my system. Therefore, I use pure method / property calls here:

 

Snip.png

 

The point is to create an element (just the tag) and a text node (the value). The text node is appended to the element, and this element is appended to the <TestData> element.

 

The output of the "Generated XML" indicator is:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?><TestData><S.no>1</S.no><Testcase>Name</Testcase><LOLIM>0</LOLIM><HILIM>5</HILIM><Rule>NA</Rule><Unit>unit</Unit><Result>Test Failed</Result></TestData>

 and the output of the "PrettyXML" indicator is:

 

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<TestData>
<S.no>1</S.no>
<Testcase>Name</Testcase>
<LOLIM>0</LOLIM>
<HILIM>5</HILIM>
<Rule>NA</Rule>
<Unit>unit</Unit>
<Result>Test Failed</Result>
</TestData>

 

I noticed that PrettyPrint always inserts two linebreaks, so I replace them with a single one in my code.

Of course, you can simply replace ">" by ">\n" in the original XML, but PrettyXML also does indentation.

 

Finally, there's one problem with your tags. Due to the XML standard, a tag must not have a whitespace in it. Otherwise, it is not valid XML.

Some of your tags have a trailing white space, and "test case" consists of two words. So, this is not allowed.

 

 

0 Kudos
Message 5 of 5
(2,065 Views)