# Unable to create XML dynamic request body using cheerio

**URL:** <https://community.postman.com/t/unable-to-create-xml-dynamic-request-body-using-cheerio/62353>\
**Category:** Help Hub\
**Tags:** cheerio, pre-request-script, dynamic-request\
**Created:** [June 18, 2024, 2:49pm UTC](https://community.postman.com/t/unable-to-create-xml-dynamic-request-body-using-cheerio/62353 "2024-06-18T14:49:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flight-candidate-490](https://avatars.discourse-cdn.com/v4/letter/f/f08c70/32.png) [@flight-candidate-490](https://community.postman.com/u/flight-candidate-490)\
**Post date:** [June 18, 2024, 2:49pm UTC](https://community.postman.com/t/unable-to-create-xml-dynamic-request-body-using-cheerio/62353/1 "2024-06-18T14:49:48Z")

</div>

I am not able to figure out how to add **attribute** values to Order & OrderLine tags. Any help is greatly appreciated

**Sample XML**

```auto
<?xml version="1.0" encoding="UTF-8"?>
<Order EMailID="" DocumentType="" EnteredBy="" OrderDate="" OrderNo=""PriorityCode="N">
    <Extn ExtnCheckoutType="GUEST"</Extn>
    <OrderLines>
        <OrderLine CarrierCode="" DeliveryMethod=""</OrderLine>
    </OrderLines>
</Order>

```

**Postman Pre-req Code**

```auto
const dynamicBody= require('cheerio').load('',{
    ignoreWhitespace: true,
    xmlMode: true
});
dynamicBody.root().append('<?xml version="1.0" encoding="UTF-8"?>\n');
dynamicBody.root().append('<Order EMailID="'+pm.environment.get('emailID')+'"DocumentType="" EnteredBy="" OrderDate="" OrderNo="" PriorityCode="N">')
console.log(dynamicBody.html());
pm.environment.set("dynamicBody",dynamicBody.html());

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [July 18, 2024, 2:50pm UTC](https://community.postman.com/t/unable-to-create-xml-dynamic-request-body-using-cheerio/62353/2 "2024-07-18T14:50:36Z")

</div>

Closed on July 18, 2024, 2:50pm UTC

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