# Xml filter : remove a useless node name before array

**URL:** <https://discuss.elastic.co/t/xml-filter-remove-a-useless-node-name-before-array/79284>\
**Category:** Logstash\
**Created:** [March 20, 2017, 3:57pm UTC](https://discuss.elastic.co/t/xml-filter-remove-a-useless-node-name-before-array/79284 "2017-03-20T15:57:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lemec\_Cinq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lemec_cinq/32/28949_2.png) [@Lemec\_Cinq](https://discuss.elastic.co/u/Lemec_Cinq)\
**Post date:** [March 20, 2017, 3:57pm UTC](https://discuss.elastic.co/t/xml-filter-remove-a-useless-node-name-before-array/79284/1 "2017-03-20T15:57:14Z")

</div>

I have a microsoft sql input and i parse an xml column thanks to the filter xml

My sql column contains xml like bellow:

```
<actors>
  <actor last_name="RICHARDSON" first_name="Ian" />
  <actor last_name="LANDAU" first_name="Martin" />
  <actor last_name="BERRY" first_name="Halle" />
  <actor last_name="DESSELLE" first_name="Natalie" />
</actors>

```

my flogstash conf file contains that samples:

```
input {
      jdbc {
         ...
        ....
          statement => "	
						  SELECT 								
						actors
						FROM [dbo].[VIEW_SQL] movie
						"
    }
}

filter
{
	
    xml {
		    source => "actors"
		    xpath => ["//actor/@last_name", "last_name"]
		    xpath => ["//actor/@first_name", "first_name"]
			target => "actors"	   
       }
}

output {
     stdout { codec => rubydebug }
}

```

It output an object:

```
 "actors": {
            "actor": [
              {
                "last_name": "RICHARDSON",
                "first_name": "Ian"
              },
              {
                "last_name": "LANDAU",
                "first_name": "Martin"
              },
              {
                "last_name": "BERRY",
                "first_name": "Halle"
              },
              {
                "last_name": "DESSELLE",
                "first_name": "Natalie"
              }
            ]
          }

```

I want to have directly an array without a object wrapper like bellow:

```
 "actors": [
              {
                "last_name": "RICHARDSON",
                "first_name": "Ian"
              },
              {
                "last_name": "LANDAU",
                "first_name": "Martin"
              },
              {
                "last_name": "BERRY",
                "first_name": "Halle"
              },
              {
                "last_name": "DESSELLE",
                "first_name": "Natalie"
              }
            ]

```

I tried (maybe badly) to use remove\_namespaces =\> true and remove\_tag =\> ["actor"] i saw in [xml docs](https://www.elastic.co/guide/en/logstash/current/plugins-filters-xml.html#plugins-filters-xml-remove_namespaces) but it dos not appear to procuce any effects

Do you know how to use the xml filterfor doing that please?

---

<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:** [March 20, 2017, 9:00pm UTC](https://discuss.elastic.co/t/xml-filter-remove-a-useless-node-name-before-array/79284/2 "2017-03-20T21:00:33Z")

</div>

I'm not sure if you can do that with the xml filter, but a ruby filter can certainly clean this up for you.

---

<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:** [April 17, 2017, 9:00pm UTC](https://discuss.elastic.co/t/xml-filter-remove-a-useless-node-name-before-array/79284/3 "2017-04-17T21:00:36Z")

</div>

Closed on April 17, 2017, 9:00pm UTC

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