Splunk Search

Xml path extract field

Annna
Explorer

<Shipment Action>

<ShipmentLines>

<ShipmentLine PrimeLine="2" />

<ShipmentLine PrimeLine="3"/>

<ShipmentLine PrimeLine="4"/>

<ShipmentLine PrimeLine="1"/>

</ShipmentLines>

</Shipment Action>

in the above xml file i have to pick out the ShipmentLine count, some times ShipmentLine increases.

I have tried different rex combination without luck, any suggestions.

output:

ShipmentLine=4 count

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "(?<ShipmentLine>ShipmentLine)\s"
| eval count=mvcount(ShipmentLine)

Since your elements don't appear to have any data (only attributes) spath/xpath will end up with empty fields which then can't be easily counted

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "(?<ShipmentLine>ShipmentLine)\s"
| eval count=mvcount(ShipmentLine)

Since your elements don't appear to have any data (only attributes) spath/xpath will end up with empty fields which then can't be easily counted

0 Karma

Annna
Explorer

Thank you so much 

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...