# There is no tags in XML

**URL:** <https://discuss.elastic.co/t/there-is-no-tags-in-xml/128124>\
**Category:** Logstash\
**Created:** [April 16, 2018, 8:08am UTC](https://discuss.elastic.co/t/there-is-no-tags-in-xml/128124 "2018-04-16T08:08:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seungtae](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seungtae/32/71413_2.png) [@seungtae](https://discuss.elastic.co/u/seungtae)\
**Post date:** [April 16, 2018, 8:08am UTC](https://discuss.elastic.co/t/there-is-no-tags-in-xml/128124/1 "2018-04-16T08:08:14Z")

</div>

Hello.

How can I write code in if condition, if there is no tags in XML.  
For example, my xml source is like this :

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<m2m:cin xmlns:m2m="http://www.onem2m.org/xml/protocols"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ty>4</ty>
 </m2m:cin>

```

> And I can write if condition like this, if there is a tag :

```
filter {
          xml { 
                remove_namespaces => true
                xpath => ["/cin/ty", "ty"]
          }

      if [ty] {
           ...
     }
}

```

> but, if there is no tag, is it right?

```
if(![ty]) {
        ...
    }

```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 16, 2018, 8:23am UTC](https://discuss.elastic.co/t/there-is-no-tags-in-xml/128124/2 "2018-04-16T08:23:45Z")

</div>

Yes, that should work.

---

<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:** [May 14, 2018, 8:23am UTC](https://discuss.elastic.co/t/there-is-no-tags-in-xml/128124/3 "2018-05-14T08:23:59Z")

</div>

Closed on May 14, 2018, 8:23am UTC

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