02-22-2011 08:15 PM
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&pid_0200#6&38f046c8&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}</path></device><device><type>Hid_Native</type><path>\\?\hid#vid_11fa&pid_0202#6&25f3bdc8&0&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.
02-23-2011 12:59 AM
02-23-2011 03:06 PM
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.
02-23-2011 06:50 PM
Hi Darin,
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.
02-24-2011 12:03 PM
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.
Attached version saved for LV8.5