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!

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...