<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: xpath command splits the result string into single-character fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108452#M28248</link>
    <description>&lt;P&gt;I not found further variants and has committed fixes to the script &lt;CODE&gt;splunk/etc/apps/search/bin/xpath.py&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;original script&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            ...
            et = etree.parse(StringIO.StringIO(myxml))
            nodes = et.xpath(path)
            values = [tostr(node) for node in nodes]
            result[outfield] = values
            ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;fixed script&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            ...
            et = etree.parse(StringIO.StringIO(myxml))
            nodes = et.xpath(path)
            if isinstance(nodes, str):
                values = nodes
            else:
                values = [tostr(node) for node in nodes]
            result[outfield] = values
            ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that the query started returns correct result&lt;/P&gt;

&lt;P&gt;I hope developers will solve the problem in a future releases&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2013 19:03:23 GMT</pubDate>
    <dc:creator>AndreyRyabov</dc:creator>
    <dc:date>2013-07-30T19:03:23Z</dc:date>
    <item>
      <title>xpath command splits the result string into single-character fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108449#M28245</link>
      <description>&lt;P&gt;Hi. There is a query that retrieves the name of XML element. It doesn't work as intended. The expected result for the example below: &lt;CODE&gt;SOAPMSG = registerOrder&lt;/CODE&gt;, but splunk generates &lt;CODE&gt;SOAPMSG=r | SOAPMSG=e | SOAPMSG=g | SOAPMSG=i | SOAPMSG=s | SOAPMSG=t | SOAPMSG=e | SOAPMSG=r | SOAPMSG=O | SOAPMSG=r | SOAPMSG=d | SOAPMSG=e | SOAPMSG=r&lt;/CODE&gt;&lt;/P&gt;

&lt;H2&gt;&lt;EM&gt;splunk query&lt;/EM&gt;&lt;/H2&gt;

&lt;PRE&gt;&lt;CODE&gt;xpath outfield=SOAPMSG "local-name(//*[local-name() = 'Body' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;&lt;EM&gt;sample input&lt;/EM&gt;&lt;/H2&gt;

&lt;PRE&gt;&lt;CODE&gt; 2013-07-25 18:59:32,542 [qtp1674856179-1896] INFO  org.apache.cxf.interceptor.LoggingInInterceptor:? - Inbound Message
    ----------------------------
    ID: 706
    Address: /webservices/agent-ws
    Encoding: UTF-8
    Content-Type: text/xml; charset=UTF-8
    Headers: {content-type=[text/xml; charset=UTF-8], connection=[close], Host=[service.ruserv.com], Content-Length=[338], SOAPAction=[""], X-Forwarded-For=[1.1.1.1], User-Agent=[Apache CXF 2.5.2], Content-Type=[text/xml; charset=UTF-8], Accept=[*/*], Pragma=[no-cache], Cache-Control=[no-cache]}
    Payload: &amp;lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&amp;gt;&amp;lt;soap:Body&amp;gt;&amp;lt;ns1:registerOrder xmlns:ns1="http://service.ruserv.com/webservices/agent"&amp;gt;&amp;lt;params&amp;gt;&amp;lt;hash&amp;gt;5fe823b563dc024bea9c75661c13364b&amp;lt;/hash&amp;gt;&amp;lt;systemId&amp;gt;109&amp;lt;/systemId&amp;gt;&amp;lt;reservationNumber&amp;gt;VOZEUB&amp;lt;/reservationNumber&amp;gt;&amp;lt;/params&amp;gt;&amp;lt;/ns1:registerOrder&amp;gt;&amp;lt;/soap:Body&amp;gt;&amp;lt;/soap:Envelope&amp;gt;
    -------------------------------------- - MDC=[PNR:, MDORDER:, XSYS:] &lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;&lt;EM&gt;result:&lt;/EM&gt;&lt;/H2&gt;

&lt;PRE&gt;&lt;CODE&gt;SOAPMSG=r | SOAPMSG=e | SOAPMSG=g | SOAPMSG=i | SOAPMSG=s | SOAPMSG=t | SOAPMSG=e | SOAPMSG=r | SOAPMSG=O | SOAPMSG=r | SOAPMSG=d | SOAPMSG=e | SOAPMSG=r
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this because script &lt;CODE&gt;splunk/etc/apps/search/bin/xpath.py&lt;/CODE&gt; not considers case when xpath-expression returns string instead collection of elements.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                ...
                et = etree.parse(StringIO.StringIO(myxml))
                nodes = et.xpath(path)
                values = [tostr(node) for node in nodes]
                result[outfield] = values
                ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this splunk error or I'm doing something wrong?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2013 22:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108449#M28245</guid>
      <dc:creator>AndreyRyabov</dc:creator>
      <dc:date>2013-07-27T22:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: xpath command splits the result string into single-character fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108450#M28246</link>
      <description>&lt;P&gt;This would probably be more productive if you could provide some sample input.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2013 05:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108450#M28246</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2013-07-28T05:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: xpath command splits the result string into single-character fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108451#M28247</link>
      <description>&lt;P&gt;sample input posted&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2013 08:55:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108451#M28247</guid>
      <dc:creator>AndreyRyabov</dc:creator>
      <dc:date>2013-07-28T08:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: xpath command splits the result string into single-character fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108452#M28248</link>
      <description>&lt;P&gt;I not found further variants and has committed fixes to the script &lt;CODE&gt;splunk/etc/apps/search/bin/xpath.py&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;original script&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            ...
            et = etree.parse(StringIO.StringIO(myxml))
            nodes = et.xpath(path)
            values = [tostr(node) for node in nodes]
            result[outfield] = values
            ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;fixed script&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            ...
            et = etree.parse(StringIO.StringIO(myxml))
            nodes = et.xpath(path)
            if isinstance(nodes, str):
                values = nodes
            else:
                values = [tostr(node) for node in nodes]
            result[outfield] = values
            ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that the query started returns correct result&lt;/P&gt;

&lt;P&gt;I hope developers will solve the problem in a future releases&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2013 19:03:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xpath-command-splits-the-result-string-into-single-character/m-p/108452#M28248</guid>
      <dc:creator>AndreyRyabov</dc:creator>
      <dc:date>2013-07-30T19:03:23Z</dc:date>
    </item>
  </channel>
</rss>

