12-05-2023 06:18 AM
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>
Solved! Go to Solution.
12-05-2023 07:48 AM
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…)
12-05-2023 07:51 AM
12-05-2023 10:11 PM
Thankyou, It really helped me to learn about fetching data from XML file.
12-05-2023 11:45 PM
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
12-06-2023 03:53 AM
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:
Regards.