ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML Update Element Text

I am struggling to find an example of how to update an already existing elment text value. I can load the XML string without a problem, but I would like to change that single element of the XML string and output the whole string with the change. Can someone point me in the right direction?

 

 

<?xml version="1.0" encoding="utf-8"?>
<TestStructure>
  <Sample>0</Sample>
</TestStructure>

 

 

as the input, and then

 

<?xml version="1.0" encoding="utf-8"?>
<TestStructure>
  <Sample>[UPDATED VALUE]</Sample>
</TestStructure>

 

 

as the output.

 

Thank you.

0 Kudos
Message 1 of 6
(6,663 Views)

If your XML-string format is fixed then you can easily insert the new value with "Format Into String" -function and then feeding the changed XML-string into the Write method.

 

Note: The "New value" can naturally also be text. In that case replace the Numeric control with String control and use %s instead of %d in string format..

 

BR,

 

Cerati

 

23238i1481BB0B1AC8AAD4

 

 

 

0 Kudos
Message 2 of 6
(6,655 Views)

Thanks, but unfortunately I can't count on the XML structure being that consistent. I was just using a small example. I'm working with a rather large XML file and I was hoping there was a way to do this a little more dynamically. For example, find the existing node I want to edit, update the value, then output the new DOM document. I can't seem to get the right combination of property and method nodes to perform this function.

0 Kudos
Message 3 of 6
(6,650 Views)

Okey. Parsing and updating the XML-content itself is easy. The updating-part I do dynamically myself using the Match pattern -function and recreating the XML-output string. I'm not sure if there's any good general help on finding the right nodes and properties. I know the methods and structure of my own WebService, so that part is no problem for me.

 

BR,

 

Cerati

0 Kudos
Message 4 of 6
(6,641 Views)

This example replaces the Sample's value. It is not a complete solution, but maybe can help you

Message 5 of 6
(6,546 Views)

Hi,

 

You can update the xml by using labVIEW drivers also.

This is also one of the way...

Try it.

 

<<Kudos are welcome>>

0 Kudos
Message 6 of 6
(6,531 Views)