LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

xml files

How do I get labview to read specific word in xml files? For example, if I have in my xml file, how do I get LabView to output 3 to an indicator? Thanks in advance.
0 Kudos
Message 1 of 14
(5,514 Views)
Well, you really have two main options. The first is simply to parse the string using LV's string functions. If your file is very simple, this may be your best option. However, if your XML file is complicated at all you will probably want to use an XML DOM Parser (can also use SAX). If you are on Windows you can use the MSXML DOM Parser through LV's ActiveX interface. You can find some help with this functionality and a nice toolkit at:

http://labxml.sourceforge.net/
Message 2 of 14
(5,513 Views)
How do I parse the string in LV? I downloaded the example on http://labxml.sourceforge.net but I don't understand what "node" is. Thanks.
0 Kudos
Message 3 of 14
(5,513 Views)
Hi,

Perhaps a good start is to read (one of the very many) "XML getting started"
tutorials on the web. (The first thing that you'll learn is what a "node"
is.)

Regards,

Wiebe.

"analog" wrote in message
news:506500000005000000E3370100-1066448259000@exchange.ni.com...
> How do I parse the string in LV? I downloaded the example on
> http://labxml.sourceforge.net but I don't understand what "node" is.
> Thanks.
0 Kudos
Message 4 of 14
(5,513 Views)
If you are using LabVIEW 7.0 there is an entire XML pallette that you can take a look at. It is under Advnaced>>Data Manipulation>>XML.

There as a VI that will read in an entire XML file and output the outputs for you. You could use those VIs to get the specific value you want.
Message 5 of 14
(5,513 Views)
You may want to have another look at how you create your XML data. Your example is not valid XML and cannot be parsed with any of the standard tools.

The normal format for a numeric indicator would be:

Voltage Limit
5.00000


If use the standard XML palette "flatten to XML" to write a cluster to a file, you can wire the same cluster into the unflatten from XML to restore the data. You will have to strip the first line from the file, since it contains a header that unflatten cannot process.

Michael Munroe
www.abcdefirm.com
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 6 of 14
(5,513 Views)
Evan wrote:

> If you are using LabVIEW 7.0 there is an entire XML pallette that you
> can take a look at. It is under Advnaced>>Data Manipulation>>XML.
>
> There as a VI that will read in an entire XML file and output the
> outputs for you. You could use those VIs to get the specific value
> you want.

sorry for my hard words, but the 6 vis in this menu are a joke! a bad joke!
I'm working with xml-files and have built some vis für me, to handle my
data. So I was really happy to see XML-Support announced in LabView!

Ok, when I dig a bit intu these vis, I find some subvis of them (which
are not in the menu) which are a bit mor usefull for me.
The Vis in the menu can just write data to an Labview-Style xml-file and
read it.

Take a look at "ParseX
MLFragments.vi" which in my oppinion contains some
more useable Code (more useable means, that they are useable in
different applications with different XML-Definitions)

I've used a lot of "Match Pattern.vi"

Writing a full XML-Parser in LabView is really hard. I started to try,
but ended up only including the cases, that are used in my application.
But I think writing some general XML-Vis completely in labview (without
using external libraries) would be a good thing.

Bye

Marco
0 Kudos
Message 7 of 14
(5,513 Views)
Michael Munroe wrote:

> You may want to have another look at how you create your XML data.
> Your example is not valid XML and cannot be parsed with
> any of the standard tools.
>
Ok, make it
and it is valid XML.
A real XML-Parser must be able to read this.

> The normal format for a numeric indicator would be:
>
> Voltage Limit
> 5.00000
>

>
> If use the standard XML palette "flatten to XML" to write a cluster to
> a file, you can wire the same cluster into the unflatten from XML to
> restore the data. You will have to strip the first line from the
> file, since it contains a header that unflatten cannot process.

Cool... This is good, when you're writing XML-file only with labview
and
read it again with labview! Or if you're creating other applications in
a way, that they write "LabView-Compliant" XML.

I understand the X in XML als "eXtensible". The XML-Support in LabView
isn't extensible in such a way. There are some good sub-vis in the
XML-Vis, but its just for exactly the XML-Format used by NI .-(

LabXML is an option, but it's using external code which is bound to a
Microsoft-Platform.

My own XML-vis are adapted to my program, but i think they can be
extended. So, if someone is interested, i could put them up for download
(in LV 4.1-format).

Bye

Marco
0 Kudos
Message 8 of 14
(5,514 Views)
The read and write XML VIs on the palette are definitely oriented towards handling LV specific XML files. As you say, the VIs that are more useful from a non-LV-centric viewpoint are the subVI's such as ParseXMLFragments.vi

I am not familiar with the Match Pattern.vi that you referred to (or did you just mean the Match Pattern node on the String palette?). Where is it located?

As for writing an XML Parser in G, it is certainly quite a task depending on how you approach it. If you want to write a robust parser which searches for all tags according to the specification (which chars are acceptable, etc), keeps track of the element tree, and provides references to each of these nodes, it would be a huge task (and G would probably not be the langua
ge you would want to use). If you ONLY want to parse XML files that you create, then you can write much simpler VIs that "cheat" and simply don't enforce most of the rules.
0 Kudos
Message 9 of 14
(5,513 Views)
>> You may want to have another look at how you create your XML data.
>> Your example is not valid XML and cannot be parsed with
>> any of the standard tools.
>>
>Ok, make it
>and it is valid XML.
>A real XML-Parser must be able to read this.

I disagree that is standard XML. A real XML-parser will not be able to read it.

You are confusing Elements and Attributes. Standard XML will contain Element tags with the data between the opening and closing tags.

Attributes are optional information applied to an Element in addition to or instead of any data. Attributes are placed within the opening Tag as a combination of name-value pairs. You CANNOT have an Attribute without an Elem
ent name.

This is the correct XML:


or

3


Michael Munroe
www.abcdefirm.com
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 10 of 14
(5,067 Views)