How can I use if condition in filter for xml

Use an xml filter with store_xml => true to parse the XML completely. Then you can access the whole XML structure via fields. If you use a stdout { codec => rubydebug } output to dump the raw event produced by Logstash it'll be easier to help.