# Sprintf on xml filter xpath

**URL:** <https://discuss.elastic.co/t/sprintf-on-xml-filter-xpath/307925>\
**Category:** Logstash\
**Created:** [June 22, 2022, 10:27pm UTC](https://discuss.elastic.co/t/sprintf-on-xml-filter-xpath/307925 "2022-06-22T22:27:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Factor3](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Factor3](https://discuss.elastic.co/u/Factor3)\
**Post date:** [June 22, 2022, 10:27pm UTC](https://discuss.elastic.co/t/sprintf-on-xml-filter-xpath/307925/1 "2022-06-22T22:27:29Z")

</div>

Hi. Is there a way to use sprintf on the xml xpath string? I have to get the node where the value is equal to a field of the event like this but I am getting no results:

```auto
	xml {
		source => "[@metadata][body]"
		store_xml => false
		xpath => ["/test/test1/fieldTable/fieldRow/field/value[text() = '%{[fieldFromEvent]}']/../..", "[@metadata][result]" ]
	}

```

---

<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:** [June 23, 2022, 12:08am UTC](https://discuss.elastic.co/t/sprintf-on-xml-filter-xpath/307925/2 "2022-06-23T00:08:51Z")

</div>

> [@Factor3](#):
>
> Is there a way to use sprintf on the xml xpath string?

No, the xml filter just [passes](https://github.com/logstash-plugins/logstash-filter-xml/blob/6f641e9bc174ecb2f64542c66e865461f33066ac/lib/logstash/filters/xml.rb#L162) the xpath option to Nokogiri, it does not sprintf anything.

---

<div class="post-metadata">

**Author:** ![Factor3](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Factor3](https://discuss.elastic.co/u/Factor3)\
**Post date:** [June 23, 2022, 12:38am UTC](https://discuss.elastic.co/t/sprintf-on-xml-filter-xpath/307925/3 "2022-06-23T00:38:54Z")

</div>

Ok thanks. I`ll just use the ruby filter for this.

---

<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:** [July 21, 2022, 12:39am UTC](https://discuss.elastic.co/t/sprintf-on-xml-filter-xpath/307925/4 "2022-07-21T00:39:03Z")

</div>

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