Splunk Search

A query to get the xml files which has the specified tags

sasireka
Loves-to-Learn Lots

I have displayed two sample xml files below.  I have to check whether a xml file has <customer-job-id> and <submission> tags. If both tags are there then we have to take it otherwise leave the xml file and move to next xml file

Sample XML file:

<?xml version="1.0" encoding="UTF-8"?><message>

<customer-job-id>cust1</customer-job-id>

<submission>

<job>

</job>

</submission></message>

 

<?xml version="1.0" encoding="UTF-8"?><message>

<customer-job-id>cust2</customer-job-id>

</message>

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Are these xml files already ingested as events? If so, you could use regex to filter them

| makeresults 
| eval xml=split("<?xml version=\"1.0\" encoding=\"UTF-8\"?><message>
<customer-job-id>cust1</customer-job-id>
<submission>
<job>
</job>
</submission></message>
|
<?xml version=\"1.0\" encoding=\"UTF-8\"?><message>
<customer-job-id>cust2</customer-job-id>
</message>","|")
| mvexpand xml
| regex xml="\<customer\-job\-id\>[^\<]+\<\/customer\-job\-id\>[\w\W]*\<submission\>"
0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...