LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search all nodes of a given type in XML

Solved!
Go to solution

Dear all

 

I am trying to find all nodes in my XML file which match a given type. I have tried with "Get all matched nodes" VI, but this only searches within one level of the document´s hierarchy at a time. 

As the structure of the XML files I´m analysing is unknown, it seems a bit complicated to guranteed an exhaustive search using this method. I´m aware of parsing methods in C# and Python which can search for all nodes in the document, regardless their hirarchical level. Does somebody know if there is one method like that in LabVIEW or any other reasonable solution?

 

Regards,

Esteban

0 Kudos
Message 1 of 5
(3,345 Views)

Read up on XPath. My experience with processing XML is not large enough to be able to say that you can, but this should put you on the right path to find the relevant XPath syntax, assuming it exists.


___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(3,320 Views)
Solution
Accepted by topic author Arroyo

Try the following xpath expression:   //NodeName

 

Ben64

Message 3 of 5
(3,314 Views)

Thanks guys. 

That solves the problem. 

Do you perhaps happen to know how can I retrieve an attribute by name when not having the certainty it exists. In other words, I want to ask first if an attrubute called "transform" exists, and if it does  retrieve its value.

I have tried with the property NameNodeMap which works good when the attribute exists. However, this property promts error it the attribute was not found. 

 

Best regards,

Esteban

0 Kudos
Message 4 of 5
(3,277 Views)

//@* will return all attributes nodes. Use a for loop to iterate the nodes name.

 

Ben64

Message 5 of 5
(3,267 Views)