input
{
    file
        {
            path => "/home/test.xml"
            start_position => "beginning"
            sincedb_path => "/dev/null"
            type => "xml"
            codec => multiline {
                    pattern => "<\?xml "
                    negate => "true"
                    what => "previous"
                }
        }
}

filter {
     mutate {
         gsub => [ "message", "[\t\r\n]", "" ]
     }

    xml{
        source => "message"
        store_xml => true
        target => "return"
        xpath => [
            "/return/items/item/@id"                , "id"                   ,
            "/return/items/item/@advertiserId"      , "advertiserId"         ,
            "/return/items/item/@saleAmount"        , "saleAmount"           ,
            "/return/items/item/@commissionAmount"  , "commissionAmount"     ,
            "/return/items/item/@advertiserName"    , "advertiserName"
        ]
    }
}

output{

   elasticsearch{
           hosts => ["http://localhost:9200/"]
           index => "parse_xml"
       }
    stdout
    {
        codec => rubydebug
    }
}

Add a code snippet to your website: www.paste.org