Forum Discussion

mtroost's avatar
mtroost
Occasional Contributor
10 years ago

wildcards in XPATH expressions?

Context: In a groovy script, a request is modified as in

holder1["//NodeA/ObjectID"]=project.getPropertyValue("objectid")
holder1["//NodeB/ObjectID"]=project.getPropertyValue("objectid")
...

You can see the node always starts with Node ans is then followed optionally by some string.

 

Question: Is it possible to make 1 XPATH expression taht matches all Node* named nodes? Is there a different way to achieve this in a different way?
The reason a groovy script is used is because lots of requests have to be changed and regular property transfer doesnt allow that (I presume).

    • mtroost's avatar
      mtroost
      Occasional Contributor

      Thank you, I think it might be something just like that. Only I wouldnt know how to apply this to my situation. I also dont get what @id refers to.

      holder1["//*[starts-with(@id,'Plaatsing') and ends-with(@id,'DAVINCIObjectID')"] =project.getPropertyValue("Plaatsing_objectid")

      This grants me an error

      XPath syntax error at char 70 on line 2 in {...ds-with(@id,'DAVINCIObjectI...}: expected "]", found " " error at line: 17
      • nmrao's avatar
        nmrao
        Champion Level 3

        Not sure if you are still having the issue. If yes, then please post the xml and what node value you wanted to get.