LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from XML file.

Solved!
Go to solution

Hi,

I have a doubt about reading data from XML file. I need to read the Channel number from channel429 and also need to verify whether each channel has TX or RX or both TX and RX. 

I have attached the XML file below.

 

Thanks.

 

Here is the XML file data:

 

<board429 xmlns="http://www.aviftech.com/Schemas/Databus/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" dataRateModifier="MINUS_7_7_PERCENT" lowSpeedSelection="INTERMEDIATE_LOW_SPEED" sdiModeEnabled="true" xsi:schemaLocation="http://www.aviftech.com/Schemas/Databus/ file:///c:/vcprojects/owl429/documents/XML/AIT_429.xsd">

<boardIndex>0</boardIndex>
<channel429> channelNumber="1" channelSpeed="HIGH_SPEED_CHANNEL">
<Tx maxAsyncronousBufferWords="256" parityEnabled="true" startWithExternalTrigger="false">
<TxScheduledLabel transferCount="1" transferPeriod="125">
<wordBuffer depth="1" label="11">
<data23>7FFFFF</data23>
</wordBuffer>
</TxScheduledLabel>
</Tx>
<Rx>
<chronMonitor>
<simpleFilter>
<labelFilterCondition label="11"/>
</simpleFilter>
</chronMonitor>
</Rx>
</channel429>
<channel429 channelNumber="2" channelSpeed="HIGH_SPEED_CHANNEL">
<Rx>
<chronMonitor>
<simpleFilter>
<labelFilterCondition label="11"/>
</simpleFilter>
</chronMonitor>
</Rx>
</channel429>
<channel429 channelNumber="3" channelSpeed="HIGH_SPEED_CHANNEL">
<Tx maxAsyncronousBufferWords="256" parityEnabled="true" startWithExternalTrigger="false">
<TxScheduledLabel transferCount="1" transferPeriod="125">
<wordBuffer depth="1" label="11">
<data23>7FFFFF</data23>
</wordBuffer>
</TxScheduledLabel>
</Tx>
<Rx>
<chronMonitor>
<simpleFilter>
<labelFilterCondition label="11"/>
</simpleFilter>
</chronMonitor>
</Rx>
</channel429>
<channel429 channelNumber="4" channelSpeed="HIGH_SPEED_CHANNEL">
<Rx>
<chronMonitor>
<simpleFilter>
<labelFilterCondition label="11"/>
</simpleFilter>
</chronMonitor>
</Rx>
</channel429>
</board429>

 

0 Kudos
Message 1 of 6
(786 Views)

Hi Hemanth8,

 


@stark8 wrote:

I have a doubt about reading data from XML file.


Which "doubt" do you have?

What have you tried and where are you stuck?

 

(As XML is just a text you can always use string functions to collect all the needed information…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(750 Views)
Solution
Accepted by topic author stark8

Hi,

 

What is your doubt, what have you tried ?

 

Have you tried with the XML parser API ? Open function palette -> File I/O -> XML -> XML Parser.

This is not easy to use, but you can read/write any XML structure with it.

 

Attached is an example for your use case.

 

Regards,

Raphaël.

0 Kudos
Message 3 of 6
(746 Views)

Thankyou, It really helped me to learn about fetching data from XML file.

0 Kudos
Message 4 of 6
(691 Views)

Hi, 

Can you provide me more information about how the Element refnum, and node result refnum in the code code are created and how it works in the code. I'm not getting any idea about how they work.

 

Thankyou

0 Kudos
Message 5 of 6
(683 Views)

Hi,

 

XML Parser VIs all use references from the "XML Parser" class hierarchy. One of the base classes is "Node", which represents a generic node in the XML document. Subclass "Document" represents the whole file, and subclass "Element" represents any node that is a child of the document. Some methods such as "Get Attribute" are only available on Elements, not generic Nodes, which is why a type specialization is needed.

 

The Refnum Constant can be created with right-click option "Create Constant" from an already existing XML wire. Then right-click on the created constant -> Select XML Parser Class -> Node -> Element.

 

The node used to type cast here is "Coerce To Type". Go to function palette -> Numeric -> Conversion -> Coerce To Type. The use of this node for a type cast is an exception for XML Parser classes, as for other class hierarchies such as VI Server or LV Objects, you normally use "To More Specific Class" and " To More Generic Class" from the Application Control palette.

 

Finally, all references created must be closed when not needed anymore. Also beware of race conditions with refnums. You must not close a refnum while using it in parallel. Use error wire to ensure the order of execution of functions.

 

I'm putting an image of the code that we are discussing so that other people can understand:

raphschru_0-1701856236739.png

 

Regards.

0 Kudos
Message 6 of 6
(646 Views)