Jump to content

read xml file


Recommended Posts

Hi,

i am new to LabView and i want to read data from a xml file and visualize it in a graph.

has anybody a clou how this is possible?

thanks a lot.

regards, thomas

I don't know about canned LV functions for this, but isn't xml just text with a particular format? If that is the case then it is a matter of learning to use the string parsing functions, match pattern, scan from string, and so on. I would also look in to open G software, this is just the sort of thing that shows up as open source.

Mike

Link to comment
isn't xml just text with a particular format?

It is "human readable" text, but the part that makes XML useful is the application of a schema.

LabVIEW's XML functions use a LabVIEW schema to read and write data. If the data to be graphed is not originally from LabVIEW, your effort to read and process the XML goes up considerably. :(

LabVIEW XML Schema

LabVIEW converts data to an established XML schema. Currently, you cannot create customized schemas, and you cannot control how LabVIEW tags each piece of data. Also, you cannot convert entire VIs or functions to XML.

The predefined XML schema that LabVIEW uses is LVXMLSchema.xsd located in the labview\vi.lib\Utility directory.

Link to comment

You can use the Microsoft XML Parser 4.0 as an ActiveX Automation control to read and parse the file for you. It takes a little bit of work, but you learn a lot in the process and end up with some usefull tools. The parser ships and installs with LabVIEW now.

1. Drop an Automation Ref control on your front panel

2. Select Microsoft XML 4.0 Class and IXMLDOMDocument2 object

A. wire an Automation Open node to that and then into ...

3. Drop an invoke method on your diagram, wire to the Ref and select "load" as the method

4. xmlSource needs a variant of a path as input

5. next wire in a property node set to "childNodes"

6. Check for parse errors, then

A. Property: length

B. loop through the child nodes getting the item , nodetype, data, etc

The rest you can work through yourself, :book:

have fun :thumbup:

Okay, I'm about to go get my second cup of coffee, so I'll also point you to:

Microsoft: Introduction to DOM - Document Object Model

Which will give you a bit more guidance (and save me from having to answer a lot more of the initial questions). As you work through this remember that it is from the perspective of the text world, so in the "Working With DOM" subtopic you can search on "childNodes" and see the function for getting the nodes. The equivalent in LabVIEW is just the initial Reference wire with a property node (item 5 above).

Etc, etc. Like I said, some work, but lets you use much more flexible tools and a much more compact and readable XML that with NI's built in stuff.

YMMV

Link to comment

Another example of access/manipulation of XML files can be seen at the attached link. Instead of creating ActiveX objects in Labview I'm utilizing external javascript to perform the load and insert functions through function calls. This eliminates the need for creation/cleanup of Labview methods/properties (since LV doesn't have garbage collection but Javascript does :D

http://forums.lavag.org/index.php?showtopi...amp;#entry19380

Link to comment

That's exactly what I'm using for currently, on my test equipment I'm writing results to a network database but needed a local storage in case the network was down. I've attached an example of the XML that I'm using to log our test results.

Download File:post-3040-1162909966.xml

Nice example Randy, thanks for sharing this!

I can see good uses for this in reporting on tests.

Link to comment
  • 4 weeks later...

A better example one of my system's test results stored in an xml.

Download File:post-3040-1165338503.xml

That's exactly what I'm using for currently, on my test equipment I'm writing results to a network database but needed a local storage in case the network was down. I've attached an example of the XML that I'm using to log our test results.

Download File:post-3040-1162909966.xml

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.