From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change value in XML file

Solved!
Go to solution

HI

I have a project which request to read out the parameter from XML file,for read out the parameter value is not a problem but the problem is how to write back the changed value to XML file

Any ideas or samples

Download All
0 Kudos
Message 1 of 9
(3,228 Views)

Not sure if this is the best way to solve the problem or not but I was able to accomplish the same thing recently just using the string match functions (search for pre-string, search for post-string and then replace the bit in the middle with your new value) and then writing the whole file content back to disk.

In my case the XML file was quite simple, I have not actually looked at your example so YMMV.

0 Kudos
Message 2 of 9
(3,194 Views)

I would recommend keeping your parameters in a LabVIEW Object.

Save them like this:

wx.png

 

Read them like this:

rx.png

 

Note: Be sure that the file reading & writing functions have "Convert EOL" unchecked.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 9
(3,189 Views)

Hi

Could you please attach your VI that I can learn how to do this

0 Kudos
Message 4 of 9
(3,174 Views)

I don't have a VI for you.

  1. If you aren't familiar with LVOOP, take the tutorial.
  2. Design a LVOOP class that will hold your data
  3. Create whatever VIs for data member access (accessor functions) that you need (be sure to make them available through property nodes)
  4. In your VI, use those property nodes for accessing your settings.
  5. Save and recall the settings, as shown in the snippets in my previous post.
"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 9
(3,158 Views)

Hi,

Could you send a picture or a < LV 16.00 version?

I am using LV 15 and would like to apply your example

Thanks

Yariv

0 Kudos
Message 6 of 9
(2,829 Views)

@Y3G wrote:

Hi,

Could you send a picture or a < LV 16.00 version?

I am using LV 15 and would like to apply your example

Thanks

Yariv


Read my previous posts.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 9
(2,811 Views)
Solution
Accepted by topic author 314159ym

You can find the XML tools in the File/XML or in the String/Seralize palettes. Also check out the example browser for working and well-documented examples of the flatten/unflatten functions.

0 Kudos
Message 8 of 9
(2,807 Views)

From the beginning you're doing everything wrong. You have an XML file but you're treating it like a simple text file. You should use the XML Parser VIs and nodes to manipulate this file and get familiar with some xpath location expressions to retrieve specific xml nodes. There is a Replace Child method you can use to change a node value.

 

I had a quick look at your XML file and I have the following interrogation, how do you  identify one ID node from another? 

 

Ben64

0 Kudos
Message 9 of 9
(2,804 Views)