# Can we Create dynamic xpath in logstash

**URL:** <https://discuss.elastic.co/t/can-we-create-dynamic-xpath-in-logstash/151574>\
**Category:** Logstash\
**Created:** [October 9, 2018, 8:45am UTC](https://discuss.elastic.co/t/can-we-create-dynamic-xpath-in-logstash/151574 "2018-10-09T08:45:41Z")\
**Posts on this page:** 2\
**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 9, 2018, 8:45am UTC](https://discuss.elastic.co/t/can-we-create-dynamic-xpath-in-logstash/151574/1 "2018-10-09T08:45:41Z")

</div>

Here is my xml file

 ![inptxml](https://us1.discourse-cdn.com/elastic/original/3X/4/4/4456da64887d27befaeb56b471fa826e8eb6e0e6.png)

## My input:

input {  
file {  
path =\> "D:/SampleELK/input.xml"  
start\_position =\> "beginning"  
sincedb\_path =\> "NUL"  
codec =\> multiline {  
pattern =\> "^"  
negate =\> true  
what =\> "previous"  
multiline\_tag =\> "multi\_tagged"  
auto\_flush\_interval =\> 1  
}  
}  
}  
filter {  
xml {  
source =\> "message"  
target =\> "parsed"  
store\_xml =\> "false"  
xpath =\> [  
"NetReport/@datetime", "date\_time",  
"NetReport/Net/@managedClientID", "cid" ,  
"/NetReport/Net/category[@name='Software']/item[@name='Software Application']//property[@name='Name']/text()", "Pname",  
"/NetReport/Net/category[@name='Software']/item[@name='Software Application']//property[@name='Caption']/text()", "Caption",  
]  
}  
}  
output{  
stdout { codec =\> rubydebug }  
}

So, my question is, in xpath, i want to pass dynamic values for @name='Software' or @name='PC Core' or @name='xyz',..... and repeat the xpath to give more dynamic values as my xml has many lines of code. Is this possible?  
Ex:-  
/NetReport/Net/category[@name='Software']/  
/NetReport/Net/category[@name='PC Core']/  
/NetReport/Net/category[@name='xyz']/  
......  
......

Please help me as i have very long xml file and cannot mention all of them in the xpath. Thanks in advance

---

<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 6, 2018, 8:45am UTC](https://discuss.elastic.co/t/can-we-create-dynamic-xpath-in-logstash/151574/2 "2018-11-06T08:45:43Z")

</div>

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