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!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...