LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading text based pseudocode in LabVIEW

Greetings everyone, as title implies, I have a xml file that I would like to read and process in LabVIEW; in particular, it defines a few hardware inputs and outputs, along with channels and the such. It is formatted in a text code style reminiscent of BASIC or C, something along the lines of:

 

 

<Module Name="VECTOR">
<RootName>VECTOR</RootName>
<Module Name="CAN">
<RootName>CAN</RootName>
<Channels NumberOfChannels="1">
<Channel Name="CAN 1">
<RootName>CANboardXL pxi Channel 1</RootName>
<Description>
</Description>
</Channel>
</Channels>
</Module>
<Module Name="VECTOR_TIMERS">
<RootName>VECTOR_TIMERS</RootName>
<Channels NumberOfChannels="1">
<Channel Name="CANboardXL pxi Channel 2_TIMER">
<RootName>CANboardXL pxi Channel 2_TIMER</RootName>
<Description>
</Description>
</Channel>
</Channels>
</Module>
</Module>

 

 

Basically, each "module" tag opens for a few submodules, declares channels, subchannels, then ends said module. It is comprehensible enough, but I can't seem to think of a reasonably simple algorythm in LV that can read it. What I would like to do is simple data processing:

 

-Read the file

-Identify main modules

-Identify submodules specific for said module

-Identify names

 

It strikes me as something that has most likely been done before so, can anyone point me to a whitepaper, thread or the such? Anyone encountered something like this? Will keep on trying on my own, but any help would be very welcome.

0 Kudos
Message 1 of 5
(2,984 Views)

Have you tried any of the LabVIEW XML vi's?

 

Specifically the XML parser?

 

BTW: The XML VIs are in the File I/O palette. 

 

========================
=== Engineer Ambiguously ===
========================
Message 2 of 5
(2,968 Views)

On one level, what you want to do isn't particularly difficult (string manipulation), but on another level, you are talking about parsing a language that has several aspects.  One element is a simple "declaration" consisting of "<", Identifier ("Module Name"), "=", Value (""Vector""), and ">".  Another, which I'll call <Element>, has the form "<", Identifier ("RootName"), <Element>, "/", Identifier ("RootName").  The interesting thing about the definition of <Element> is that it is recursive, as it includes itself in its definition.  [Actually, Element has two possibilities -- it can also be a simple ElementIdentifier, such as "VECTOR"].

 

You can write recursive routines in LabVIEW (they are called "reentrant"), but if you haven't dealt with recursion before, it is easy to get mixed up.  See what the XML parser can do for you.

 

Bob Schor

Message 3 of 5
(2,937 Views)

Its good to go with XML Parser, which will give exact output based on Xpath Query.

----------------------------------------------------------------------------------------------------------------
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
(2,874 Views)

Thanks everyone, sorry for the radio silence, it's been a heckuva week. So far I'm experimenting with xml pallete, with so far acceptable results, some polishing needed most likely due to inexperience on the usage. Will post if I find something relevant.

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