# Logstash xml parse error

**URL:** <https://discuss.elastic.co/t/logstash-xml-parse-error/300624>\
**Category:** Logstash\
**Created:** [March 24, 2022, 7:14pm UTC](https://discuss.elastic.co/t/logstash-xml-parse-error/300624 "2022-03-24T19:14:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elwdipath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elwdipath/32/96262_2.png) [@elwdipath](https://discuss.elastic.co/u/elwdipath)\
**Post date:** [March 24, 2022, 7:14pm UTC](https://discuss.elastic.co/t/logstash-xml-parse-error/300624/1 "2022-03-24T19:14:35Z")

</div>

Hey all, new to logstash.

I'm running into an error when trying to parse an empty xml element.

```auto
failed to parse field [xml.record.person.agedata.dob] of type [text] in document with id 'DA9jvH8BhCQVGJZR4sKN'. Preview of field's value: '{nil=true}'", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:990"

```

Here's an example XML message:

```auto
<entry>
<person>
<title xsi:nil="true"/>
<job xsi:nil="true"/>
<names>
<first_name>John</first_name>
<last_name>Doe</last_name>
</names>
<ageinfo>
<dob xsi:nil='true'/>
</ageinfo>
</person>
</entry>

```

And my config

```auto
input {
    beats {
        port => 5044
    }
}

filter {
    if [message] =~ /<\?xml/ { drop {} }
       
    xml {
        namespaces => {
            "xsi" => "http://www.w3.org/2001/XMLSchema-instance"
            "xsd" => "http://www.w3.org/2001/XMLSchema"
            "xmlns" => "http://www.w3.org/2001/XMLSchema"
        }
        store_xml => false
        source => "message"
        target => "doc"
        force_array => true
        
        xpath =>
            [
                "/entry/person/title/text()", "title",
                "/entry/person/job/text()", "job",
                "/entry/person/position/text()", "position",
                "/entry/person/names/first_name/text()", "firstName",
                "/entry/person/names/last_name/text()", "lastName",
                "/entry/person/agedata/dob/text()", "dob",
            ] 
    }
    mutate { 
        remove_field => ["@version","beat","count","fields","input_type","offset","type","host","tags","path","log"]
        
    }
}

output {
    elasticsearch {
        hosts => ["elasticsearch:9200"]
        index => "test3"
    }
    stdout { codec => rubydebug {metadata => true} }
}

```

Version 7.14

---

<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:** [April 21, 2022, 7:14pm UTC](https://discuss.elastic.co/t/logstash-xml-parse-error/300624/2 "2022-04-21T19:14:48Z")

</div>

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