# div() or divide() with Xpath denominators

**URL:** <https://community.cdata.com/t/div-or-divide-with-xpath-denominators/688>\
**Category:** CData Arc\
**Tags:** question, math-formatters\
**Created:** [April 9, 2024, 10:53am UTC](https://community.cdata.com/t/div-or-divide-with-xpath-denominators/688 "2024-04-09T10:53:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [April 9, 2024, 10:53am UTC](https://community.cdata.com/t/div-or-divide-with-xpath-denominators/688/1 "2024-04-09T10:53:26Z")

</div>

Is is possible to pass values retrieved using xpath() into the div([value]) or divide([value]) Math formatters?

I want to do something like this in an XML Map connector

_[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos)&nbsp; | div(xpath(ConsignmentNode/DefinitionOfGoods/TotalFull)| add(xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf)) | add(xpath(ConsignmentNode/DefinitionOfGoods/TotalOversize))))]_!--endfragment\>!--startfragment\>

which in pseudo code is

Weight = Total Kilos / (Full + Half + Oversize)

Things like “….| div(2)” work, but I can’t seem to get it to work with values from other parts of the message.

Even simplifying to

_[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | divide(xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf))]_

gets the same error:

_Formatter divide failed in the evaluation of \<weight\>[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | divide(xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf))]\</weight\>. The error was: Error parsing BigDecimal value [xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf)]. Value: 2000_

---

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [April 9, 2024, 11:15am UTC](https://community.cdata.com/t/div-or-divide-with-xpath-denominators/688/2 "2024-04-09T11:15:02Z")

</div>

My syntax was wrong…..

Corrected to

```xml
[xpath(ConsignmentNode/DefinitionOfGoods/TotalKilos) | div([xpath(ConsignmentNode/DefinitionOfGoods/TotalFull)| add ([xpath(ConsignmentNode/DefinitionOfGoods/TotalHalf) | add([xpath(ConsignmentNode/DefinitionOfGoods/TotalOversize)])])]) ]

```

---

<div class="post-metadata">

**Author:** ![lohith](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/lohith/32/1848_2.png) [@lohith](https://community.cdata.com/u/lohith)\
**Post date:** [April 11, 2024, 4:02am UTC](https://community.cdata.com/t/div-or-divide-with-xpath-denominators/688/3 "2024-04-11T04:02:52Z")

</div>

Hi Russel,

Glad to hear you were able to resolve it yourself! If you have any more questions or need further assistance in the future, feel free to reach out.
