Dashboards & Visualizations

Extract field from XML attribute/element values, spath doesn't quite work out of the box, cant find a solution with xpath

phillip_rice
Explorer

Hi, I have the below example XML, when i process this through spath i get the following fields with values created automatically

xpath "//table/elem/@key" outfield=name
The first is just the values
answer
question

The second contains the values of the answer and question.

xpath "//table/elem/" outfield=name
true
false
is it true or false

etc

I am trying to extract 2 fields based on the key="answer" and key="name"

any idea how i can achieve this using spath/xpath etc

`
true
is it true or false

true
is it true or false

false
is it true or false
`

Thanks

Tags (3)
0 Karma
1 Solution

phillip_rice
Explorer

Found the solution

xpath "//table/table/elem[@key='answer']" outfield=AAA

View solution in original post

phillip_rice
Explorer

Found the solution

xpath "//table/table/elem[@key='answer']" outfield=AAA

phillip_rice
Explorer
<table>
<elem key="answer">true</elem>
<elem key="name">Is it true or false</elem>
</table>
<table>
<elem key="answer">true</elem>
<elem key="name">Is it true or false</elem>
</table>
<table>
<elem key="answer">false</elem>
<elem key="name">Is it true or false</elem>
</table>


Adding sample xml
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...