--- title: "Calculator variant with XML file" slug: "tutorials-http-examples-calculator-xml" updated: 2025-11-18T09:53:27Z published: 2025-12-04T02:44:08Z canonical: "docs.lobstersoftware.com/tutorials-http-examples-calculator-xml" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Calculator variant with XML file The aim is to build a calculator, as in the previous example, with input and output of an XML file. Here you will find an example XML with a division of two values: Input: ```plaintext  10  3  / ``` Output: ```plaintext 3.333333 ``` In this example, the division is to be output with 6 decimal places. The calculation is almost identical to example 2, only the type of the variable *var_result* must be selected as *Float*, *Double* or *BigDecimal*. ## Step 1 - Create profile You are welcome to clone the existing calculator profile from example 2 and save it under a new name, e.g. *Lobster_Tutorial_HTTP_calculator_xml*. Adjust the following settings in the *Main settings*: - *Document type*: *XML* - *Encoding*: *UTF-8* - Mapping is activated. ![images/download/attachments/137305189/ex3_basis_data_1-version-2-modificationdate-1686649964718-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/ex3_basis_data_1-version-2-modificationdate-1686649964718-api-v2.png) ## Step 2 - Adjust input and format settings In phase 1, adjust the following settings for HTTP: - *URL address suffix*: *calculator_xml* - *Mime type of response*: *application/xml* ![images/download/attachments/137305189/ex3_phase1-version-2-modificationdate-1686650010583-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/ex3_phase1-version-2-modificationdate-1686650010583-api-v2.png) In phase 2, the parser is told where the root node of the input is located. ![images/download/attachments/137305189/ex3_phase2-version-2-modificationdate-1686650049322-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/ex3_phase2-version-2-modificationdate-1686650049322-api-v2.png) ## Step 3 - Mapping In phase 3, the source structure can be created via menu option 'structure generated from file analysis'. To do this, save the sample XML from the input as a file and upload it via 'File analysis...'. Please make sure that you tick the checkbox "no complex fields". An initial node *RESULT* is required within the target structure. Below this, the value of *OP1* is first written into the variable *var_result* and then the calculation is initiated via the *OP2* and the *OPR* source field. The number of decimal places can be defined via the parameter ***e*** of function *calculate and save variable*. Use the [val syntax for naming the fields](/docs/en/document-type-xml-names) so no extra node is created for the field in the XML output. ![images/download/attachments/137305189/ex3_phase3-version-2-modificationdate-1686650080487-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/ex3_phase3-version-2-modificationdate-1686650080487-api-v2.png) The [XMLNoTemplateUnit](/docs/en/xml-no-template-unit) in phase 5 generates the output format. The root node name must be specified here. ![images/download/attachments/137305189/ex3_phase5-version-2-modificationdate-1686650116853-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/ex3_phase5-version-2-modificationdate-1686650116853-api-v2.png) The data is sent back to the client via the Response "Custom class" with class "PassBackDataResponse" and the content setting "Output of IU". You can test the request again via Postman by adjusting the URL and the body of the request accordingly.