# Xml multi elemts parsing

**URL:** <https://discuss.elastic.co/t/xml-multi-elemts-parsing/159552>\
**Category:** Logstash\
**Created:** [December 5, 2018, 2:09pm UTC](https://discuss.elastic.co/t/xml-multi-elemts-parsing/159552 "2018-12-05T14:09:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![povisx1](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@povisx1](https://discuss.elastic.co/u/povisx1)\
**Post date:** [December 5, 2018, 2:09pm UTC](https://discuss.elastic.co/t/xml-multi-elemts-parsing/159552/1 "2018-12-05T14:09:28Z")

</div>

Hello,

I have a problem with multi elements XML

I try take values like this:

> xml {  
> source =\> "parsedXML"  
> remove\_namespaces =\> "true"  
> force\_array =\> "false"  
> force\_content =\> "true"  
> xpath =\> ["//msisdn/text()", "msisdn",  
> "//ocsIp/text()", "ocsIP",  
> "//sessionId/text()","sessionId",  
> "//sgsnIp/text()", "sgsnIp",  
> "//ggsnIp/text()", "ggsnIp",  
> "//sgsnMccMnc/text()", "sgsnMccMnc",  
> "//apn/text()", "apn",  
> "//imsi/text()", "imsi",  
> "//imei/text()", "imei",  
> "//userLocationInfo/text()", "userLocationInfo",  
> "//chargingId/text()", "chargingId",  
> "//ip/text()", "ip",  
> "//chargingCharacteristic/text()", "chargingCharacteristic",  
> "//qos/text()", "qos",  
> "//chargingRuleName/text()", "chargingRuleName",  
> "//requestNumber/text()", "requestNumber",  
> "//creditControlFailureHandlingType/text()", "creditControlFailureHandlingType",  
> "//ccSessionFailover/text()", "ccSessionFailover",  
> "//ccRequestType/text()", "ccRequestType",  
> "//ccRequestNumber/text()", "ccRequestNumber",  
> "/cca/resultCode/text()", "totalResultCode",  
> "//msccList/mscc", "parsedMscc",  
> "//requestType/text()", "requestType"  
> ]  
> store\_xml =\> "false"  
> }  
> xml {  
> source =\> "parsedMscc"  
> remove\_namespaces =\> "true"  
> #target =\> "mscc"  
> force\_array =\> "false"  
> force\_content =\> "true"  
> xpath =\> ["/mscc/inputOctetsGranted/text()", "inputOctetsGranted",  
> "/mscc/outputOctetsGranted/text()", "outputOctetsGranted",  
> "/mscc/totalOctetsGranted/text()", "totalOctetsGranted",  
> "/mscc/timeGranted/text()", "timeGranted",  
> "/mscc/quotaConsumptionTime/text()", "quotaConsumptionTime",  
> "/mscc/quotaHoldingTime/text()", "quotaHoldingTime",  
> "/mscc/volumeQuotaThreshold/text()", "volumeQuotaThreshold",  
> "/mscc/resultCode/text()", "resultCode",  
> "/mscc/message/text()", "message",  
> "/mscc/ratingGroup/text()", "ratingGroup",  
> "/mscc/finalUnitIndication/text()", "finalUnitIndication"  
> ]  
> store\_xml =\> "false"  
> }  
> mutate {  
> remove\_field =\> ["parsedXML", "message", "msg","parsedMscc"]  
> }

but then I get json like this :

> {  
> "\_index": "ocs-2018.12.05",  
> "\_type": "doc",  
> "_id": "AWd-cYVFO5tqPqZWL1T_",  
> "\_version": 1,  
> "\_score": null,  
> "\_source": {  
> "resultCode": [  
> "2001"  
> ],  
> "@version": "1",  
> "outputOctetsGranted": [  
> "0"  
> ],  
> "offset": 514999799,  
> "ccRequestNumber": [  
> "19"  
> ],  
> "totalResultCode": [  
> "2001"  
> ],  
> "ccRequestType": [  
> "2"  
> ],  
> "host": "miram.int.bite.lt",  
> "quotaConsumptionTime": [  
> "0"  
> ],  
> "ratingGroup": [  
> "2040","2050"  
> ],  
> "@timestamp": "2018-12-05T12:57:03.214Z",  
> "totalOctetsGranted": [  
> "15728640"  
> ],  
> "prospector": {  
> "type": "log"  
> },  
> "ts": "2018-12-05 14:09:18,018",  
> "inputOctetsGranted": [  
> "0"  
> ],  
> "beat": {  
> "hostname": "sssss",  
> "version": "6.2.3",  
> "name": "miram.int.bite.lt"  
> },  
> "loglevel": "INFO",  
> "timeGranted": [  
> "6407"  
> ],  
> "tags": [  
> "beats\_input\_codec\_plain\_applied"  
> ],  
> "msisdn": [  
> "370000000"  
> ],  
> "volumeQuotaThreshold": [  
> "0"  
> ],  
> "source": "/ocs/mobicents/server/bite/log/ocs.log",  
> "quotaHoldingTime": [  
> "0"  
> ]  
> },  
> "fields": {  
> "@timestamp": [  
> 1544014623214  
> ]  
> },  
> "sort": [  
> 1544014623214  
> ]  
> }

my xml looks like:

```
<?xml version="1.0"?>
<cca>
	<ccRequestType>1</ccRequestType>
	<ccRequestNumber>1000</ccRequestNumber>
	<msisdn>37000000</msisdn>
	<resultCode>4012</resultCode>
	<msccList>
		<mscc>
			<inputOctetsGranted>0</inputOctetsGranted>
			<outputOctetsGranted>0</outputOctetsGranted>
			<totalOctetsGranted>0</totalOctetsGranted>
			<timeGranted>0</timeGranted>
			<quotaConsumptionTime>0</quotaConsumptionTime>
			<quotaHoldingTime>0</quotaHoldingTime>
			<timeQuotaThreshold>0</timeQuotaThreshold>
			<volumeQuotaThreshold>0</volumeQuotaThreshold>
			<resultCode>4012</resultCode>
			<message>OK</message>
			<ratingGroup>1000</ratingGroup>
			<finalUnitIndication/>
		</mscc>
		<mscc>
			<inputOctetsGranted>0</inputOctetsGranted>
			<outputOctetsGranted>0</outputOctetsGranted>
			<totalOctetsGranted>0</totalOctetsGranted>
			<timeGranted>0</timeGranted>
			<quotaConsumptionTime>0</quotaConsumptionTime>
			<quotaHoldingTime>0</quotaHoldingTime>
			<timeQuotaThreshold>0</timeQuotaThreshold>
			<volumeQuotaThreshold>0</volumeQuotaThreshold>
			<resultCode>4012</resultCode>
			<message>OK</message>
			<ratingGroup>2000</ratingGroup>
			<finalUnitIndication/>
		</mscc>
	</msccList>
</cca>

```

I need to make json like xml ( if you check mscc this is my multi elemnt xml)

---

<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:** [January 2, 2019, 2:09pm UTC](https://discuss.elastic.co/t/xml-multi-elemts-parsing/159552/2 "2019-01-02T14:09:41Z")

</div>

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