Dashboards & Visualizations

Regex to read xml data dynamic

keeplearningbud
New Member

Hi..

I am trying to create a dashboard which extracts errorCode field from multiple xmls. Xpath for it would be different for different outputs. For ex: for createUser it is abc and for deleteUser it would be xyz. I need to have the xpath dynamic which extracts errorCode alone. I am trying with below regular expression which I know makes no sense. Please help.

alt text

alt text

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

hi keeplearningbuddy,
using this regex you can take all erroCodes and test it at https://regex101.com/r/9oqQxH/1

\<errorCode>(?<errorCode>[^\<]*)\<\/errorCode>

if instead you like to determine errorCode related to createUser, you can use this regex and test it at https://regex101.com/r/AhlTiY/1

\<createUser\>[^\<]*\<errorCode>(?<errorCode>[^\<]*)\<\/errorCode>

Bye.
Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

hi keeplearningbuddy,
using this regex you can take all erroCodes and test it at https://regex101.com/r/9oqQxH/1

\<errorCode>(?<errorCode>[^\<]*)\<\/errorCode>

if instead you like to determine errorCode related to createUser, you can use this regex and test it at https://regex101.com/r/AhlTiY/1

\<createUser\>[^\<]*\<errorCode>(?<errorCode>[^\<]*)\<\/errorCode>

Bye.
Giuseppe

0 Karma

keeplearningbud
New Member

Thanks Giuseppe. This worked 🙂

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...