# Help with parsing XML content

**URL:** <https://discuss.elastic.co/t/help-with-parsing-xml-content/27445>\
**Category:** Logstash\
**Created:** [August 15, 2015, 8:31pm UTC](https://discuss.elastic.co/t/help-with-parsing-xml-content/27445 "2015-08-15T20:31:25Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jjdepaul](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jjdepaul](https://discuss.elastic.co/u/jjdepaul)\
**Post date:** [August 17, 2015, 4:51pm UTC](https://discuss.elastic.co/t/help-with-parsing-xml-content/27445/3 "2015-08-17T16:51:51Z")

</div>

OK, I've switched to xpath. Logstash is now successfully parsing out the values I need, but they are not present in my Document after successful run... How can I add the four new fields to my doc? A short example would be perfect.

Here is my config:

```
filter {
  if [path] =~ "SLIC" {
        mutate { replace => { "type" => "slic" } }
  } else {
        mutate { replace => { "type" => "sysout" } }
  }
  grok {
    match => [
          "message",
          "^\[%{DATESTAMP:tslice}\] %{GREEDYDATA} HttpClient.submit - POST : %{GREEDYDATA:inxml}"
    ]
  }
  if "_grokparsefailure" in [tags] {
          drop { }
  }  
  xml {
      source => "inxml"
      target => "xmldata"
      store_xml => "false"
      xpath => ["/BillingAndCosting/ControlArea/SenderId/text()","senderid"]
      xpath => ["/BillingAndCosting/ControlArea/WaterMark/text()","watermark"]
      xpath => ["/BillingAndCosting/ControlArea/RecordCount/text()","nbrofaccounts"]
      xpath => ["/BillingAndCosting/ControlArea/TimeStamp/text()","timeofdelivery"]
  }
}

```

Also, is there a way to count nodes that may appear in the XML structure, like in this example below. How can that be reflected in the config file?!

```
  <xsl:for-each select="BillingAndCosting/DataArea/CustomerAccount">
    <p> Account <xsl:value-of select="ExternalKey" /> has <xsl:value-of select="count(BillingData)"/> invoices</p>
  </xsl:for-each>
```

---

_[View the full topic](https://discuss.elastic.co/t/help-with-parsing-xml-content/27445)._
