Unable to create XML dynamic request body using cheerio

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

Sample XML

<?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

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());

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