# Unable to load xml file in logstash

**URL:** <https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318>\
**Category:** Logstash\
**Created:** [October 6, 2018, 1:32pm UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318 "2018-10-06T13:32:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [October 6, 2018, 1:32pm UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318/1 "2018-10-06T13:32:25Z")

</div>

Hello, can you please provide a sample example to upload xml file using logstash. I have tried a lot but unable to upload an xml file in logstash in windows machine. Waiting for the response.

Ex: My XML file is as follows,

--stations--  
--station--  
--id--Value1--/id--  
--name\>Value2--/name--  
--/station--  
--/stations--

My conf file is as follows,  
input  
{  
file  
{  
path =\> "C:\Users\LENOVO\Downloads\stations.xml"  
start\_position =\> "beginning"  
#sincedb\_path =\> "/dev/null"  
exclude =\> "\*.gz"  
type =\> "xml"  
codec =\> multiline {  
pattern =\> ""  
negate =\> "true"  
what =\> "previous"  
}  
}  
}  
filter  
{  
xml  
{  
source =\> "message"  
store\_xml =\> false  
target =\> "stations"  
xpath =\> [  
"/stations/station/id/text()", "station\_id",  
"/stations/station/name/text()", "station\_name"  
]  
}

}

output  
{  
elasticsearch  
{  
codec =\> json  
hosts =\> "localhost"  
index =\> "xmlns24"  
}  
stdout  
{  
codec =\> rubydebug  
}  
}

Please help me , i am not getting any output,,

---

<div class="post-metadata">

**Author:** ![Emmanuel\_DEMEY](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emmanuel_demey/32/7912_2.png) [@Emmanuel\_DEMEY](https://discuss.elastic.co/u/Emmanuel_DEMEY)\
**Post date:** [October 6, 2018, 2:48pm UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318/2 "2018-10-06T14:48:35Z")

</div>

Do you see any logs in the sdtout ?  
It looks like the 9200 port is missing in your Elasticsearch output config.

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [October 6, 2018, 6:29pm UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318/3 "2018-10-06T18:29:09Z")

</div>

thanks for the reply my elastic search is working fine.

when i run this on logstash, i am getting the following output as attached in the image

 ![output](https://us1.discourse-cdn.com/elastic/original/3X/4/8/48527f90eb7b33bbc2ed936283e640f91b03e4c9.png)

Waiting for your response.

Thanks in advance,  
Balu

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [October 7, 2018, 1:50pm UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318/4 "2018-10-07T13:50:16Z")

</div>

Hello, in my windows machine, i have changed my path from as shown below,  
path =\> "C:\Users\LENOVO\Downloads\stations.xml"  
to  
path =\> "C:/Users/LENOVO/Downloads/stations.xml"

and sincedb\_path =\> "NUL" ![out](https://us1.discourse-cdn.com/elastic/original/3X/6/3/6355cff947eda5ca7661970f991d64a597b0cbc6.png)

and it is generating the response as shown above.  
Please help me get correct output.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [October 24, 2018, 10:21am UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318/5 "2018-10-24T10:21:17Z")

</div>

The correct output is obtained for below input code, hope this helps other people,  
Also, max\_lines number changes based on the maximum number of lines present in your xml file

input  
{  
file  
{  
path =\> "C:/Users/LENOVO/Downloads/stations.xml"  
start\_position =\> "beginning"  
sincedb\_path =\> "NUL"  
codec =\> multiline {  
pattern =\> "^\<?stations.\*\>"  
negate =\> "true"  
what =\> "previous"  
auto\_flush\_interval =\> 1  
max\_lines =\> 3000  
}  
}  
}  
filter  
{  
xml  
{  
source =\> "message"  
target =\> "parsed"  
store\_xml =\> "false"  
xpath =\> [  
"/stations/station/id/text()", "station\_id",  
"/stations/station/name/text()", "station\_name"  
]  
}  
mutate {   
remove\_field =\> ["message"]   
}  
}

output  
{  
stdout  
{  
codec =\> rubydebug  
}  
}

---

<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:** [November 21, 2018, 10:21am UTC](https://discuss.elastic.co/t/unable-to-load-xml-file-in-logstash/151318/6 "2018-11-21T10:21:17Z")

</div>

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