# Logstash XML file

**URL:** <https://discuss.elastic.co/t/logstash-xml-file/69149>\
**Category:** Logstash\
**Created:** [December 15, 2016, 10:40am UTC](https://discuss.elastic.co/t/logstash-xml-file/69149 "2016-12-15T10:40:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![magikbyte](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@magikbyte](https://discuss.elastic.co/u/magikbyte)\
**Post date:** [December 15, 2016, 10:40am UTC](https://discuss.elastic.co/t/logstash-xml-file/69149/1 "2016-12-15T10:40:29Z")

</div>

Hello,  
I need to parse XML file and send content to EL. It's work for XML input without space before xml tag like that :  
`<?xml version="1.0" encoding="utf-8"?>`  
`<file>`  
`<tag1>tag1</tag1>`  
`<tag2>tag2</tag2>`  
`</file>`  
but when file have space bebore XML tag,  
eg: **SPACE** \<?xml version="1.0" encoding="utf-8"?\>  
Logstash don't send any data. I know that i should write a pattern to remove space. I use strip without success.  
this is my pattern:  
codec =\> multiline {  
pattern =\> "^\<?file .\*\>"  
negate =\> "true"  
what =\> "previous"  
auto\_flush\_interval =\> 5  
}

Thanks for help

---

<div class="post-metadata">

**Author:** ![magikbyte](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@magikbyte](https://discuss.elastic.co/u/magikbyte)\
**Post date:** [December 15, 2016, 1:22pm UTC](https://discuss.elastic.co/t/logstash-xml-file/69149/2 "2016-12-15T13:22:09Z")

</div>

Hi,  
I found solution. I use gsub to remove space  
gsub =\> ["message"," **SPACE** ﻿\<?xml version="1.0" encoding="utf-8"?\>",""]

Thanks

---

<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:** [January 12, 2017, 1:22pm UTC](https://discuss.elastic.co/t/logstash-xml-file/69149/3 "2017-01-12T13:22:45Z")

</div>

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