LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading from XML file is too slow

I am trying to read some values from XML file, it takes about 1 or 2 minutes to finish reading, my xml file has about 4000 xml elements. Does anyone know this is normal or something wrong? How could make it faster?

Thank you
0 Kudos
Message 1 of 10
(5,241 Views)
how do you access the xml file? using the labview xml tools, or do you use the ms xml parser?
i recommend use the xml parser using dom model and xpath-querys this should speed up the access to your xml file
have further questions feel free to ask
0 Kudos
Message 2 of 10
(5,241 Views)
Hello Jun.z,


We will need a little more information on how you a reading the file to know why it is taking so long. One possibility may be in your file reading routine and not the XML parsing. Things like opening and closing a file every read can definitely slow down an application.

Please let us know how we can help.

Regards,

Matt F
0 Kudos
Message 3 of 10
(5,241 Views)
Thanks for your reply, the attached files are the vi and xml file, reading from xml file takes about 39s(sorry, not 1 or 2 minutes), xml elements processing loop take about 50ms. My xml file has about 2000 elements.

Thank you.
Download All
0 Kudos
Message 4 of 10
(5,241 Views)
it seems that "read from xml-file" is somewhat slow.

in the attachment are two vi's.

the first one reads your xml-file in two 1D-Arrays (one for var-names the other one for the values, for use with "search 1D-Array") and in one 2D-Array.

the second one is a 'replacement' for "read from xml-file".

but i suggested that you use a spreadsheet-file, it make it somewhat easier to save and loads the vars.
Download All
0 Kudos
Message 5 of 10
(5,241 Views)
Thank you. Could you please save the files in Labview 7.0 format? I can't open 7.1 files.
0 Kudos
Message 6 of 10
(5,241 Views)
of course, here they are
Download All
0 Kudos
Message 7 of 10
(5,241 Views)
It is much faster, thanks a lot.
0 Kudos
Message 8 of 10
(5,241 Views)
Catweazle,

In your xmlFile_GetElements_(Array).vi the logic gate which controls the termination of the while loop needs to be AND rather than OR. As drawn it never stops.

Very nice improvement on the original.

Lynn
0 Kudos
Message 9 of 10
(5,241 Views)
fine if it helps others... i hope NI will not be angry *fg*

thx for your bug-report, i do not test the sub.vi until now.
exchange the OR with an AND, solves the problem with the endless-loop, but error checking will not work (the loop only stops if no error AND no start-tag is found)
changing the loop termination condition and putting the NOT from the error condition to the no_starttag_flag do both. correctly stops the loop when error occurs OR no further elements found.

i attached the new sub.vi for version 7.0 and 7.1, also but some colors in the logo, for your convinience 😉

catweazle
Download All
0 Kudos
Message 10 of 10
(5,241 Views)