LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write out XML without <LVData> and <Version>

Solved!
Go to solution

Hello,

I try to read XML file, and change the node value and the write out as new xml file.

I successfully did change node value.

However, unnecessary parts <LVData>, <Version> and its pairs </brabra> is added as header and footer. This parts annoy me in post process with other application.

 

Is there any way to avoid added these unneeded parts when write out as new XML file.

 

It would be appriciated if you help.

LabVIEW version is 19.

 

IXML summary.PNG

Download All
0 Kudos
Message 1 of 6
(1,283 Views)

21 is to new for me...

 

If you use the LabVIEW From\To XML functions, you're stuck with those...

 

You can get the XML string (I think) and remove it from the string.

 

Or, build your own XML string entirely.

 

Or use the XML library to either build the XML or get the child and it's XML.

 

If you're going to use XML, I'd not even consider the to\from xml functions and go straight to either LV's XML library or a .NET xml library.

 

If you have a say in it, most people prefer JSON...

0 Kudos
Message 2 of 6
(1,273 Views)
Solution
Accepted by topic author kzn4605

Hi,

 

Since you are using the VI "Write to XML File", if you open its diagram you can see this:

raphschru_0-1694603645973.png

 

So it is easy to see that the header and footer are always written and there is no configuration that can change that.

What you can do is copy this code and create your own "Write to XML" subVI that writes exactly how you want.

 

Also, what is the purpose of your whole VI ? It seems highly complicated just to modify an XML file. Since you are using the XML parser API, why not use it to modify the nodes and write to file ? (instead of recreating the whole XML string from scratch and then using "Write to XML File" VI).

 

Regards,

Raphaël.

Message 3 of 6
(1,266 Views)

@kzn4605 wrote:

Hello,

I try to read XML file, and change the node value and the write out as new xml file.

I successfully did change node value.

However, unnecessary parts <LVData>, <Version> and its pairs </brabra> is added as header and footer. This parts annoy me in post process with other application.

 

Is there any way to avoid added these unneeded parts when write out as new XML file.

 

It would be appriciated if you help.

LabVIEW version is 19.

 

IXML summary.PNG


When XML was first introduced to LabVIEW the XML file functions used a LabVIEW specific Schema that actually changed.  That Schema was, and still isn't an exact cross application XML format although,  The XML specification permits customized Schemas.  But, other applications may not find the LabVIEW Schema Definition file.

 

LabVIEW also has implemented a XML API that does follow a more transferable method.   Those functions do use DOMuserdefref32.dll published by the World Wide Web Consortium (W3C)  the disadvantage with that API is W3C has NOT published a version of DOMuserdefref32.dll that is threadsafe so it is about 50x slower than the LabVIEW only API implementatiom


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(1,256 Views)

Hi, Raphaël

Thank you for reply.

As your suggestion, I copied VI and changed it as shown below. I achieved what I wanna.

 

The purpose of my VI is to change the value, change algorithm is judged by python node return(T or F).

however the number of object is random, It depends on file.(in this case, number of object is 3)

So I calculate the number of object each time at first, then create the array, its array size is number of object.

As you question, I would like to use XML parser API, however, for the above reasons and to the best of my knowledge, 

I created VI in this way as you can see.

 

Regards, 

kzn

 

0 Kudos
Message 5 of 6
(1,199 Views)

If you have to read and write XML files with an arbitrary structure (not necessarily generated by LabVIEW initially, I recommend using the XML Parser API entirely, with the very useful function "Get All Matched Nodes" that makes use of XPaths to easily retrieve the nodes you are interested in. Then you can simply read or write their text content.

 

Attached is your example simplified with this technique.

 

Regards,

Raphaël.

Message 6 of 6
(1,143 Views)