Can anyone help on the “Execute XPath” - “XPathExpression”?
I’d like to obtain the value of element “cbc:ID” as shown below (in yellow):
The challenges here are:
All elements are tagged with namespace (See attachement)
Semi-dynamic structure. The main tree structure does not change largely, however small change may occur. For instance the element “cac:Party” maybe gone. And “cac:Contact” becomes the direct child of “cac:AccountingCustomerParty”
The method using “xdoc.element” or “xdoc.desendants” are usful in other cases.
But, in my case the structure changes may only be resolved by XPath (from what I’ve been digging so far).
Somthing like: string(/path/to/[local-name()=‘ele_name1’/[local-name()=‘ele_name2’]/text()[1]), where there could be a number of elements between “ele_name1” and “ele_name2”.
The challenge here is that XPathExpression won’t return any value.
To have a dynamic path, the “//*” can be inserted between each “local-name”, for instance:
XPathExpression as: “string(//*[local-name()=‘Element1’]//*[local-name()=‘Element2’]//*[local-name()=‘Element3’]/text()[1])”
As long as the following cretiria is met, the value can be retrieved:
@hellitonwoo
Perfect, yes the * is like a wildcard to the namespace. When its working so just flag the solving post as solution. Other forummembers can so benefit from it. Thanks