# XML filter help

**URL:** <https://discuss.elastic.co/t/xml-filter-help/54050>\
**Category:** Logstash\
**Created:** [June 27, 2016, 2:25pm UTC](https://discuss.elastic.co/t/xml-filter-help/54050 "2016-06-27T14:25:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sar](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@sar](https://discuss.elastic.co/u/sar)\
**Post date:** [June 27, 2016, 2:25pm UTC](https://discuss.elastic.co/t/xml-filter-help/54050/1 "2016-06-27T14:25:31Z")

</div>

Hi,

I'm trying to import a log file which contains an XML message embedded in each line in to elasticsearch using logstash. I use KV filter to extract the XML message.

Then I'm trying to extract several values from this XML message. I have been trying this for hours now, but I think I'm missing some thing or I haven't understood the XML plugin well.

Therefore I need your help to figure this out.

An example XML message,

```
<?xml version="1.0" encoding="UTF-8"?>
<msgType1 xmlns="http://www.w1.org/" xmlns:ds="http://www.w3.org" xmlns:trlh="http://www.w2.com" Version="5-8">
    <header>
        <messageId messageIdScheme="http://www.w4.com">12345</messageId>
        <sentBy>w4</sentBy>
        <sendTo>abc</sendTo>
        <creationTimestamp>20160516</creationTimestamp>
    </header>
    <pCId correlationIdScheme="http://www.w4.com">3456</pCId>
    <CId CIdScheme="http://www.w4.com">1233</CId>
    <sequenceNumber>1</sequenceNumber>
    <party id="party1">
        <partyId>test1</partyId>
    </party>
    <party id="party2">
        <partyId>test2</partyId>
    </party>
</msgType1>

```

My Filter,

```
xml {
        store_xml => false
        source => "src"
        target => "msgType1"
        xpath => ["/msgType1/sequenceNumber", "sequenceNumber"]
    }

```

If I use the XML filter above, a field for sequenceNumber is not created.  
However if I comment the first line (i.e. #store\_xml =\> false), multiple fields are generated, but still the field sequenceNumber is not generated.

Any advice on this is highly appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![purbon](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@purbon](https://discuss.elastic.co/u/purbon)\
**Post date:** [June 27, 2016, 3:47pm UTC](https://discuss.elastic.co/t/xml-filter-help/54050/2 "2016-06-27T15:47:54Z")

</div>

Hi,  
to know a bit more, can you share your LS version and the full config you're using?

- purbon

---

<div class="post-metadata">

**Author:** ![sar](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@sar](https://discuss.elastic.co/u/sar)\
**Post date:** [June 27, 2016, 3:57pm UTC](https://discuss.elastic.co/t/xml-filter-help/54050/3 "2016-06-27T15:57:17Z")

</div>

Hi Purbon,

I'm using logstash-2.0.0

Config file is,

```
input {
    file {
        path => "D:\PROJECTS\kibana\log_file"
        start_position => beginning
    sincedb_path => "D:\PROJECTS\kibana\since_db_tmp"
        delimiter => "

"
    }
}

filter {

    kv{ field_split => "\u0001"}

    
    if [message] =~ /^$/ {
         drop {}
         }

    xml {
        store_xml => false
        source => "src"
        target => "msgType1"
        xpath => ["/msgType1/sequenceNumber", "sequenceNumber"]
    }
}

output {
    elasticsearch {
        hosts => ["127.0.0.1:9200"]
        action => "index"
        index => "logstash-test"
        template_overwrite => true
    }
    stdout { }
}

```

Thanks.

---

<div class="post-metadata">

**Author:** ![sar](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@sar](https://discuss.elastic.co/u/sar)\
**Post date:** [June 27, 2016, 4:20pm UTC](https://discuss.elastic.co/t/xml-filter-help/54050/4 "2016-06-27T16:20:49Z")

</div>

One more thing,

The XML message is multi line as shown in my first post. It is not received as a single line.

---

<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:** [June 29, 2016, 6:03am UTC](https://discuss.elastic.co/t/xml-filter-help/54050/5 "2016-06-29T06:03:30Z")

</div>

Yeah, this seems like a bug in the xml filter. The destination field is populated if I change the XPath query to "/\*" but with "/msgType1" I get nothing.

---

<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:** [July 6, 2017, 4:50am UTC](https://discuss.elastic.co/t/xml-filter-help/54050/6 "2017-07-06T04:50:33Z")

</div>


