Hello Expert,
Please help me arrive on a regex to extract a xml node in a xml field.
I have a field value like below
@yuanliu is correct, but for a pure rex solution, try this regex
\<message id=\"Payload\">(?<Payload>[\s\S]+?)\<\/message
Thanks for the help. All three are good answers.
| rex field=Action "(?ms)messages>(?<Payload>.+)<\/messages"
@yuanliu is correct, but for a pure rex solution, try this regex
\<message id=\"Payload\">(?<Payload>[\s\S]+?)\<\/message
If your document is conformant XML, you should use builtin commands such as spath; regex will be difficult to maintain if the format, or syntax, or schema change. In your case, assuming you have a field named "xml", you can do
| spath input=xml path=Reponse.messages.message.UpdateAccountRq
Your sample data gives the following
Reponse.messages.message.UpdateAccountRq | xml |
<AccountId>123465</AccountId> <NewStatus>Active</NewStatus> | <Reponse status="failure"> <messages> <message id="Payload"> <UpdateAccountRq> <AccountId>123465</AccountId> <NewStatus>Active</NewStatus> </UpdateAccountRq> </message> </messages> </Reponse> |