# Struggling to parse XML using Logstash

**URL:** <https://discuss.elastic.co/t/struggling-to-parse-xml-using-logstash/248616>\
**Category:** Logstash\
**Created:** [September 15, 2020, 7:19am UTC](https://discuss.elastic.co/t/struggling-to-parse-xml-using-logstash/248616 "2020-09-15T07:19:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Igor\_Olikh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_olikh/32/46434_2.png) [@Igor\_Olikh](https://discuss.elastic.co/u/Igor_Olikh)\
**Post date:** [September 15, 2020, 7:19am UTC](https://discuss.elastic.co/t/struggling-to-parse-xml-using-logstash/248616/1 "2020-09-15T07:19:17Z")

</div>

I have a lot of logs each one stored in the following xml file:

[![enter image description here](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d6438f6700e67838659a16728b61eecdcf32dade.png)](https://i.stack.imgur.com/NMPfe.png)

What I want to achieve:

- create fields in elasticsearch that stores the following:

MainActivityText = "TEST"

My config file:

```auto
input {
    file {
        path => "/path/*.xml"
        start_position => "beginning"
        type => "xml"
        sincedb_path => "/dev/null"
        codec => multiline {
            pattern => "<Remarks"
            charset => "ISO8859-8"
            what => "previous"
            negate => "true"
        }
    }
} 

filter {
    xml {
        source => "message"
        store_xml => false
        force_array => false
        target => "Remarks"
        xpath => [
            "/Remarks/MainActivity/text()", "MainActivityText"
        ]
    }
} 

output {
    file
    {
        path => "/path/output.txt"
    }

    elasticsearch
    {
          hosts => ["https://elastic:9200"]
          user => "elastic"
          password => ""
          ssl => true
          ssl_certificate_verification => true
          cacert => "/path/sub_ca.crt"
          index => "test-%{+YYYY.MM}"
    }
}

```

But the output is not what I expect to get. I just get the whole xml stored in the index.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 13, 2020, 7:19am UTC](https://discuss.elastic.co/t/struggling-to-parse-xml-using-logstash/248616/2 "2020-10-13T07:19:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
