04-07-2020 04:29 AM
What I get from OP is that the "position" text in the XML (quite confusing) is just a temporary thing.
The question (AFAIK) is how to get the position without the text, with an XPath query.
04-07-2020 06:30 AM
@Wiebe, this is also my understanding that the position text in the comment node is a temporary thing. I just realise that the paragraph explaining the code did not shows (I had problem with the quote button not showing anything prior so probably related to that).
My code doesn't use the "position" text, it uses the XPATH position() function.
The strategy is to get to the target node using the Name attribute (e.g. step112) and then to get a reference to the parent node of that target node. From there I use the xpath position() function in a while loop to iterate throughout the child node of the parent node until I reach the target node.
TABLE[position()=1] returns the first child, TABLE[position()=2] returns the 2nd child, ...
I added a TABLES (with an S) root node to the XML to insure that all the TABLE node have a parent node.
I left the comments with the "position" text to be able to validate the results.
Ben64
04-07-2020 06:30 AM
Hi @ben64, when I surfing on intenet, I found the same expression that you have in the code "count(a/b[.='tsr']/preceding-sibling::*)+1", but I don't know how to use it in LabVIEW.
04-07-2020 06:36 AM
04-07-2020 08:24 AM
@ben64 wrote:
@Wiebe, this is also my understanding that the position text in the comment node is a temporary thing. I just realise that the paragraph explaining the code did not shows (I had problem with the quote button not showing anything prior so probably related to that).
My code doesn't use the "position" text, it uses the XPATH position() function.
😐🌴 (:face palm:). Like I said, confusing.
04-07-2020 08:34 AM
@dgd.gomez wrote:
Hi @ben64, when I surfing on intenet, I found the same expression that you have in the code "count(a/b[.='tsr']/preceding-sibling::*)+1", but I don't know how to use it in LabVIEW.
Found that one too. "count" is included in the XPath standard (see this, (counting elements)).
It doesn't work in LabVIEW, but I think that is because the XPath implementation LabVIEW uses isn't complete or old.
04-07-2020 11:14 AM
04-07-2020 11:52 AM
@ben64 wrote:
The XPATH implementation in LabVIEW is only valid for location path.
The help says it implements XPath version 1.0. XPath currently is version 3.1...
V1.0 does include count, and it's not working, so there seem to be other limitations. It there any reference to these limitations?
04-07-2020 11:55 AM
BTW. my solution would be to switch XML library. LV's native XML lib is slow and not up to date.
I'd look around a bit on the forum, but here's one alternative.
04-07-2020 01:15 PM