I need a way to remove namespaces from an XPath expression, e.g if it’s something like this:
/ns1:ElementOne/ElementTwo/ns2:ElementThree
it should become
/ElementOne/ElementTwo/ElementThree
Namespaces could differ within the XPath (ns1, ns2 in the example above) and can be applied at the beginning of the Xpath, e.g.
ns3:ElementFour
Regex? Any ideas?
Thanks!
The regex bellow matches the namespace format:
EDIT:
For the ancestor part you can use the updated regex:
So the final solution does the following, It searches for the previously stated structure with all alphanumerical + underscore string format followed by a ‘:’ character which is not followed by a second ‘:’ character. Hope this helps.