# Parsing xml using logstaash xpath

**URL:** <https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274>\
**Category:** Logstash\
**Created:** [February 9, 2018, 4:38pm UTC](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274 "2018-02-09T16:38:48Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 12, 2018, 6:01pm UTC](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274/22 "2018-02-12T18:01:08Z")

</div>

> [@wwalker](#):
>
> I would think his multiline would look like:
> 
> codec =\> multiline {  
> pattern =\> "\<station\>"  
> negate =\> "true"  
> what =\> "previous"  
> }

That does not work. For an input like this we want either one event, containing the entire stations XML, or 2 events, each containing an entire station.

\<stations\>  
\<station\>  
\<id\>1\</id\>  
\</station\>  
\<station\>  
\<id\>2\</id\>  
\</station\>  
\</stations\>

What we get is the first station ("\<station\>\n\<id\>1\</id\>\n\</station\>") but not the second, since there is no third station to trigger the end of the second event, and EOF does not trigger emission of an event.

---

<div class="post-metadata">

**Author:** ![Karanushah.1992](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@Karanushah.1992](https://discuss.elastic.co/u/Karanushah.1992)\
**Post date:** [February 12, 2018, 6:03pm UTC](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274/23 "2018-02-12T18:03:27Z")

</div>

stations not station

---

<div class="post-metadata">

**Author:** ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)\
**Post date:** [February 12, 2018, 6:14pm UTC](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274/24 "2018-02-12T18:14:44Z")

</div>

> [@Karanushah.1992](#):
>
> I have another config file with same since\_db path and that works perfectly fine

Have you tried it? I'd suggest turning on debug logging and watching the output. May want to change your stat\_interval to something less frequent, the default 1s will flood the log making it hard to pull relevant data.

---

<div class="post-metadata">

**Author:** ![Karanushah.1992](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@Karanushah.1992](https://discuss.elastic.co/u/Karanushah.1992)\
**Post date:** [February 12, 2018, 6:17pm UTC](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274/25 "2018-02-12T18:17:53Z")

</div>

The below config files work perfectly

input {  
file {  
path =\> "C:\Users\186181152\Downloads\stations4.xml"   
start\_position =\> "beginning"  
sincedb\_path =\> "/dev/null"  
codec =\> multiline {  
pattern =\> "^"  
what =\> "previous"  
}

}  
}

filter  
{  
xml  
{  
source =\> "message"  
target =\> "doc"  
store\_xml =\> false  
xpath =\> ["//station/name/text()","station\_name"]  
xpath =\> ["//station/id/text()","station\_id"]  
}  
}

output  
{  
elasticsearch  
{  
action =\> "index"  
hosts =\> "localhost:9200"  
workers =\> 1  
}  
stdout  
{

```
}

```

}

---

<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:** [March 12, 2018, 6:18pm UTC](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274/26 "2018-03-12T18:18:21Z")

</div>

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

[Previous page](https://discuss.elastic.co/t/parsing-xml-using-logstaash-xpath/119274.md?page=1)
