Jaymer wrote
Given that I would always know a path to the desired element, is it possible for a simple REGEX function to return my element?
Depends upon how you define simple.
Using the examples you provided, the following will get the elements you want.
Given:
BO = ComplexRegEx
Your first XML example stored in ComplexRegEx.FirstXML
Your second XML example stored in ComplexRegEx.SecondXML
The following rules will extract the required values
Rule1
ComplexRegEx.City=REPLACE_PATTERN(REPLACE_PATTERN(REPLACE_PATTERN(ComplexRegEx.FirstXML, CR(), ''), '^.*\<LegalAddr\>.*\<City\>', ''), '\</City\>.*$', '')
Rule2
ComplexRegEx.UnitPrice=TRIM(REPLACE_PATTERN(REPLACE_PATTERN(REPLACE_PATTERN(ComplexRegEx.SecondXML, CR(), ''),'^.*Pump.*?\<UnitPrice\>',''),'\</UnitPrice\>.*$',''))
Results
ComplexRegEx.City = San Pablo3
ComplexRegEx.UnitPrice=15
Explanation:
Each rule executes the REPLACE_PATTERN 3 time.
The first REPLACE_PATTERN removes all new line symbols because RegEx works on a line by line bases. If the actual XML comes in 1 long line, this is not needed.
The second REPLACE_PATTERN removes everything before the required value
The third REPLACE_PATTERN removes everything after the required value. Leaving only the required value left.
Note: the FirstXML and SecondXML fields are not changed by these rules.