# Logstash xml filter

**URL:** https://discuss.elastic.co/t/logstash-xml-filter/147285
**Category:** Logstash
**Created:** [September 5, 2018, 1:50am UTC](https://discuss.elastic.co/t/logstash-xml-filter/147285 "2018-09-05T01:50:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![xodn0812](https://avatars.discourse-cdn.com/v4/letter/x/c5a1d2/32.png) [@xodn0812](https://discuss.elastic.co/u/xodn0812)
#### Post date: [September 5, 2018, 1:50am UTC](https://discuss.elastic.co/t/logstash-xml-filter/147285/1 "2018-09-05T01:50:46Z")

</div>

I want to store the following xml format data at once.

> ```
> <title>name</title>
> <destination>my name</destination>
> <log>hi~ my name is taewoo!</log>
> <date>2018-09-04T09:00:00</date>
> 
> ```

However, each field is stored separately, creating three documents.

Below is the configuration file.  
How can I fix all the fields in one document?

```
input {
    file {
        path => "/usr/local/ELK/logstash-6.3.2/config/test1.xml"
        start_position => "beginning"
        type => "xml"
    }
}

filter {
    xml {
        remove_namespaces => true
        source => "message"
        xpath => ["/title", "title",
                  "/destination", "destination",
                  "/log", "log",
                  "/date", "date"]
        target => "doc"
        store_xml => true
    }
}
output {
    elasticsearch {
        hosts => ["127.0.0.1:9200"]
        index => "t4"
# document_type => "test"
        user => "elastic"
        password => "root123"

    }
    stdout {}
}

```

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [September 5, 2018, 9:12am UTC](https://discuss.elastic.co/t/logstash-xml-filter/147285/2 "2018-09-05T09:12:57Z")

</div>

The file input reads files line by line. If you want to join multiple lines into a single event you should use a multiline codec.

---

<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 3, 2018, 9:13am UTC](https://discuss.elastic.co/t/logstash-xml-filter/147285/3 "2018-10-03T09:13:09Z")

</div>

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