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!

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, ...