LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Xml String

Hi,

 

I have pull out some information from a device, it is written in xml format. As below.. All in continuous without spacing.

 

<codedevices><device><type>Serial_Port</type><path>COM1</path></device><device><type>Serial_Port</type><path>COM2</path></device><device><type>Hid_Keyboard</type><path>\\?\hid#vid_11fa&amp;pid_0200#6&amp;38f046c8&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}</path></device><device><type>Hid_Native</type><path>\\?\hid#vid_11fa&amp;pid_0202#6&amp;25f3bdc8&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}</path><maxpacket>65</maxpacket></device></codedevices>

 

May I know how can i pull out the text content by xml elements?

 

Example:

1. Device:<type>Serial_Port</type><path>COM1</path></device><device><type>Serial_Port</type>

<path>COM2</path>

2. Type: Hid_Keyboard

3. maxpacket: 65

 

Appreciate your feedback.

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

Hi TanTan,

you can use the EasyXML Toolkit to get the data you need.

 

Mike

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

With simple XML you can easily parse it using the built-in XML VIs and a little XPath.  Here I read the parameters of each device into a variant.  For a given device you can use 'Get XML Variant' to retrieve the text portion.  Or, adapt this example to your own data structure.

 

EasyXMLParsing.png

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

Hi Darin,

 

1.JPG

 

In my xml string functions, only attached options are available. My labview version is 8.5.1.

 

May i know where to get the others xml functions?

 

I am appreciated that if you can share me the vi. 

 

Thanks.

 

 

0 Kudos
Message 4 of 5
(2,356 Views)

The XML parser was added in LV8.6 and the XPath VIs added in LV9.  With simple XML like this, it is easy to do the same thing with Regexes.

 

EasyXMLParsing_mod.png

 

Attached version saved for LV8.5

Message 5 of 5
(2,333 Views)