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!

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...

State of Splunk Careers 2024: Maximizing Career Outcomes and the Continued Value of ...

For the past four years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

Data-Driven Success: Splunk & Financial Services

Splunk streamlines the process of extracting insights from large volumes of data. In this fast-paced world, ...