How could I speed the below code up? I believe the Array Map method would speed things up but I don't know how to implement this due to the nested loop. Maybe there is another method I'm unaware of? I am more familiar with VBA and trying to learn Google Script very Sloooooowly!
var document = XmlService.parse(response);
var root = document.getRootElement();
var NS = XmlService.getNamespace("urn:ebay:apis:eBLBaseComponents");
var ack = root.getChildText('Ack', NS);
var time = root.getChildText('Timestamp', NS);
var version = root.getChildText('Version', NS);
var build = root.getChildText('Build', NS);
var shortmessage = root.getChildText('ShortMessage', NS);
var longmessage = root.getChildText('LongMessage', NS);
var sr = root.getChildren('SaleRecord', NS);
for (var i = 0; i < sr.length; i++) {
var orderids = sr[i].getChildren('SellingManagerSoldTransaction', NS);
for (var L = 0; L < orderids.length; L++) {
var srn = orderids[L].getChild('SaleRecordID', NS).getText();
var sku = orderids[L].getChild('CustomLabel', NS).getText();
var title = orderids[L].getChild('ItemTitle', NS).getText();
var qty = orderids[L].getChild('QuantitySold', NS).getText();
var lineitem = orderids[L].getChild('OrderLineItemID', NS).getText();
var name = sr[i].getChild('ShippingAddress', NS).getChild('Name', NS).getText();
var pcode = sr[i].getChild('ShippingAddress', NS).getChild('PostalCode', NS).getText();
var status = sr[i].getChild('OrderStatus', NS).getChild('CheckoutStatus', NS).getText();
var paidtime = sr[i].getChild('OrderStatus', NS).getChild('PaidTime', NS).getText();
var shipped = sr[i].getChild('OrderStatus', NS).getChild('ShippedStatus', NS).getText();
var email = sr[i].getChild('BuyerEmail', NS).getText();
var price = sr[i].getChild('SalePrice', NS).getValue();
var totprice = sr[i].getChild('TotalAmount', NS).getValue();
sheet.appendRow([srn, sku, title, qty, price, totprice, lineitem, name, pcode, status, paidtime, shipped, email]);
}
XML Response Example: