From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Query XML Document for All Matching Different Expressions Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This example VI shows how to query a XML document for three different expressions and will return all the results it finds. 


Description
In this specific example (with the attached file as the XML document) it will find five matches for each expression. If you need to parse a large XML document, using this VI with your specific XPath Expressions can be done quick and easy.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Choose the path of the XML Document
  2. If you choose the Example XML Document, the expressions will work with the XML document.
  3. If you choose a different XML document, fill out the necessary XPath Expressions.
  4. Click Run.

 

Additional Information or References
VI Snippet

3-390.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

National Instruments
Applications Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
TroyK
Active Participant
Active Participant
on

Why is each segment in a while loop?

You MUST close all references including all of those coming out of the node result array in the xpath search function.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument