Splunk Search

How to get multiple values from xml using xpath and spath?

ritesh14
Explorer

I am trying to get multiple values from xml as shows below

I have tried xpath and spath and both shows nothing

I am looking for ResponseCode, SimpleResponseCode and nResponseCode

here is the sample xml for reference

 

 

 

 

 

| makeresults 
| eval _raw="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <soapenv:Body>
        <ns3:LogResponse xmlns:ns2=\"http://randomurl.com/sample1\"
                            xmlns:ns3=\"http://randomurl.com/sample2\">
            <ResponseCode>OK</ResponseCode>
            <State>Simple</State>
            <Transactions>
                <TransactionName>CHANGED</TransactionName>
            </Transactions>
            <Transactions>
                <TransactionData>CHANGE_SIMPLE</TransactionData>
            </Transactions>
            <ServerTime>1649691711637</ServerTime>
            <SimpleResponseCode>OK</SimpleResponseCode>
            <nResponseCode>
                <nResponseCode>OK</nResponseCode>
            </nResponseCode>
            <USELESS>VALUES</USELESS>
            <MORE_USELESS>false</MORE_USELESS>
        </ns3:LogResponse>
    </soapenv:Body>
</soapenv:Envelope>" 
| xpath outfield=

 

 

 

 

 

Labels (2)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults 
| eval _raw="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <soapenv:Body>
        <ns3:LogResponse xmlns:ns2=\"http://randomurl.com/sample1\"
                            xmlns:ns3=\"http://randomurl.com/sample2\">
            <ResponseCode>OK</ResponseCode>
            <State>Simple</State>
            <Transactions>
                <TransactionName>CHANGED</TransactionName>
            </Transactions>
            <Transactions>
                <TransactionData>CHANGE_SIMPLE</TransactionData>
            </Transactions>
            <ServerTime>1649691711637</ServerTime>
            <SimpleResponseCode>OK</SimpleResponseCode>
            <nResponseCode>
                <nResponseCode>OK</nResponseCode>
            </nResponseCode>
            <USELESS>VALUES</USELESS>
            <MORE_USELESS>false</MORE_USELESS>
        </ns3:LogResponse>
    </soapenv:Body>
</soapenv:Envelope>"
| spath soapenv:Envelope.soapenv:Body.ns3:LogResponse.ResponseCode output=ResponseCode
| spath soapenv:Envelope.soapenv:Body.ns3:LogResponse.SimpleResponseCode output=SimpleResponseCode
| spath soapenv:Envelope.soapenv:Body.ns3:LogResponse.nResponseCode.nResponseCode output=nResponseCode

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults 
| eval _raw="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <soapenv:Body>
        <ns3:LogResponse xmlns:ns2=\"http://randomurl.com/sample1\"
                            xmlns:ns3=\"http://randomurl.com/sample2\">
            <ResponseCode>OK</ResponseCode>
            <State>Simple</State>
            <Transactions>
                <TransactionName>CHANGED</TransactionName>
            </Transactions>
            <Transactions>
                <TransactionData>CHANGE_SIMPLE</TransactionData>
            </Transactions>
            <ServerTime>1649691711637</ServerTime>
            <SimpleResponseCode>OK</SimpleResponseCode>
            <nResponseCode>
                <nResponseCode>OK</nResponseCode>
            </nResponseCode>
            <USELESS>VALUES</USELESS>
            <MORE_USELESS>false</MORE_USELESS>
        </ns3:LogResponse>
    </soapenv:Body>
</soapenv:Envelope>"
| spath soapenv:Envelope.soapenv:Body.ns3:LogResponse.ResponseCode output=ResponseCode
| spath soapenv:Envelope.soapenv:Body.ns3:LogResponse.SimpleResponseCode output=SimpleResponseCode
| spath soapenv:Envelope.soapenv:Body.ns3:LogResponse.nResponseCode.nResponseCode output=nResponseCode
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...