LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert XML to Numeric Data

I am using an app,Sensor Node that delivers a realtime XML, which i wish to convert to true data so that I can use the numerical data. The length of data is not fixed. Please help

I am new to labview.

 

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><NodeId>2</NodeId><Accelerometer><Accelerometer1>-0.2059013396501541</Accelerometer1><Accelerometer2>4.879383087158203</Accelerometer2><Accelerometer3>8.47547435760498</Accelerometer3></Accelerometer><Gyroscope><Gyroscope1>0.01491415686905384</Gyroscope1><Gyroscope2>0.0031958906911313534</Gyroscope2><Gyroscope3>-0.02024064213037491</Gyroscope3></Gyroscope><Proximity>100.0</Proximity><LinearAcceleration><LinearAcceleration1>1.505866289138794</LinearAcceleration1><LinearAcceleration2>-4.389438629150391</LinearAcceleration2><LinearAcceleration3>5.768225193023682</LinearAcceleration3></LinearAcceleration><LightIntensity>42.0</LightIntensity><NoiseLevel>0.0</NoiseLevel><TimeStamp>1480865017310</TimeStamp>

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

Hi Psaxena,

 

delivers a realtime XML, which i wish to convert to true data so that I can use the numerical data.

You might do it "manually" by simple string parsing: search for patterns like "1>" to find interesting parts in your string. Then use ScanFromString to convert the values.

Or you might employ the XML functions coming with LabVIEW…

 

What have you tried so far? Where are you stuck?

 

I am new to labview.

That's ok, we all needed to start with LabVIEW once. But you surely go through those free online resources to learn LabVIEW!?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,681 Views)

XML parsing is not working, it is not identifying the the UTF-8 enconding.

Parsing a string is picking only one value i need to extract all of them.

Now i am trying the String subset and Match regular command to extract each data seperately.

 

0 Kudos
Message 3 of 5
(2,653 Views)

Hi Psaxena,

 

XML parsing is not working, it is not identifying the the UTF-8 enconding.

I cannot comment on this as I don't use XML so often.

 

Parsing a string is picking only one value i need to extract all of them.

When you want to do something more than once you could create a function and call this function in a loop. This is valid for (nearly) all programming languages I heard of…

 

Now i am trying the String subset and Match regular command to extract each data seperately.

I would create a function that takes a keyword as input and outputs the data between the corresponding XML tags.

Example: the function input is "bla1", the functions searches for <bla1>…</bla1> and outputs the data between the <bla1> tags.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,634 Views)

Why are you not using the XML functions in LabVIEW? 

They can do all the work for you. 

 

If you any problems with code, the show us the code.

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