Jump to content

How to make a custom XML file?


Recommended Posts

Hi,

Anyone know how to make a custom XML-file (write).

Need to change the name of parameters and so on.

LabView's write-xml only make a predefined format.

Is it an idea to use write to spreadsheet file and write one string at a time?

Thanks to any thoughts !

LabVIEW internet toolkit includes an XML tools so you can write whatever you want. You can also use Microsofts XML parser if you don't want to purchase the internet toolkit. See attached how to use it in a very basic fashion. This one just parses, doesn't write. Good luck. Download File:post-2966-1145750064.vi

Link to comment
  • 4 months later...
  • 5 months later...

well if labview supports oop you should be able to inherit the built in xml writer and override the render event which takes a string builder.. talking more of how its done in .net

if your using measurement studio you should be able to create an xmldocument object

which has properties to createElement,

xmldoc->save(filestreamobject);

-lm

Link to comment

QUOTE(leblanc @ Mar 14 2007, 03:58 PM)

well if labview supports oop you should be able to inherit the built in xml writer and override the render event which takes a string builder.. talking more of how its done in .net

Merely because LV has OO capacities does not mean that 20 years of libraries have been rewritten along OO principles.

Link to comment

This may be an unpopular alternative :unsure: , but

XML is marked-up plain text. One can read/write XML files without much hassle at all.

I have developed an XML database that records serial numbers and tracks changes to modules.

It took me about a day to write the core vi's needed to interface with the XML database (add, remove, modify, and resolve).

I decided to go this route because of cost and speed. A purpose-built text-parser will (usually :D ) always perform better than a general purpose XML parser.

I <heart> XML

-H

Link to comment

QUOTE(Doon @ Mar 14 2007, 07:10 PM)

This may be an unpopular alternative :unsure: , but

XML is marked-up plain text. One can read/write XML files without much hassle at all.

I have developed an XML database that records serial numbers and tracks changes to modules.

It took me about a day to write the core vi's needed to interface with the XML database (add, remove, modify, and resolve).

I decided to go this route because of cost and speed. A purpose-built text-parser will (usually :D ) always perform better than a general purpose XML parser.

Yes, but writing a generic text-based parser will probably not be very generic.

You may want to look into using MSXML -- It's an ActiveX object that you can use in LabVIEW. I've built a set of VIs that use this object to read/write XML files. It takes a while to get up to speed on all the methods/properties of MSXML, but after that, it's super easy to use!

Link to comment

QUOTE(Jeff Plotzke @ Mar 14 2007, 07:23 PM)

You may want to look into using MSXML -- It's an ActiveX object that you can use in LabVIEW. I've built a set of VIs that use this object to read/write XML files. It takes a while to get up to speed on all the methods/properties of MSXML, but after that, it's super easy to use!

I'll second that. I recently used a colleague's MSXML implementation on some RF testing. The XML defined "objects" of one or more test instruments, and then setup parameters for those instrument/objects on some in-house legacy test executives. The implementation was written with a high degree of abstraction and inheritance and was very poorly documented, (I mean NO documentation, actually) so it was hard to figure out how it worked. However, once you did figure it out, and study up on the MSXML objects and methods, it became very easy to setup very powerful hierarchy trees of data, objects and actions (methods). The XML schema he defined used a lot of attributes, so it was much more compact and readable than the native NI implementation. The only downside was that it was custom and limited to a subset of datatypes. The NI XML is not (yet) very nice to read, but it has the advantage of easy read/write for any complex data type you throw at it.

I'll also second the plug for the LabXML toolkit above. Sorry I cannot post a copy of my colleague's tools, but they are proprietary and they'd take away my birthday if I broke the NDA.

Link to comment

QUOTE(Jeff Plotzke @ Mar 14 2007, 05:23 PM)

Yes, but writing a generic text-based parser will probably not be very generic.

Touché

I would like to qualify my solution. It does result in purpose-built (i.e., very specific) interfaces. Further, the interfaces I have written do not actively consider validation or well-formedness (By design, the generated XML is both valid and well-formed [as long as no one modifies the XML externally :rolleyes: ]). Straight text-parsing is definitely worth considering for simple (i.e., shallow) XML files.

The XML database I have implemented is no more than three levels deep, and is very wide at the top level. For anything more complex, I agree with Mr. Plotzke that a generic XML parser is a better solution. I cannot comment on the utility of the native LabVIEW Internet Toolkit as I have not used it, but I hear it's pretty cool.

Cheers!

--H

Link to comment

QUOTE(Doon @ Mar 15 2007, 02:51 PM)

I cannot comment on the utility of the native LabVIEW Internet Toolkit as I have not used it, but I hear it's pretty cool.

I'll comment that I remember older versions of the Internet Toolkit having a huge memory leak in the XML VIs (I believe it was version 7.1 or so...) I haven't tested anything newer, so I hope it's corrected, but if you're planning to open many XML files over time, you may want to watch your memory if you're using the Internet Toolkit.

Link to comment

You may want to check out this (xml using javascript) piece of code I put into the repository, it utiilizes javascript to write to an xml file with the msxml active x objects. The benefit of doing this through the javascript interface is the garbage collection built into javascript where as using the msxml active x objects in Labview can be cumbersome due to the continuous opening and closing of references when working through an xml file.

While the example is simplistic, with a little investigation you can turn it into a powerful tool for documentation. The following is an example of an xml file being generated on one of my test systems. XML file example

QUOTE(Kalmar @ Apr 22 2006, 02:01 PM)

Hi,

Anyone know how to make a custom XML-file (write).

Need to change the name of parameters and so on.

LabView's write-xml only make a predefined format.

Is it an idea to use write to spreadsheet file and write one string at a time?

Thanks to any thoughts !

Link to comment
  • 11 months later...
  • 11 months later...

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.