Bhagavad-Gita As It Is

Category: Hinduism
Author: A. C. Bhaktivedanta
4.4

Comments

by anonymous   2018-02-18

I'm trying to write a script in Google Sheets that uses an ISBN number to query the Amazon Product Advertising API for product information. I'm totally stuck parsing the XML. I've exhausted my knowledge and could use some help understanding this.

So far this is what I have:

function myFunction(isbn) {
  var app = SpreadsheetApp;
  var activeSheet = app.getActiveSpreadsheet().getActiveSheet();

  var endpoint = 'webservices.amazon.com',
      uri = '/onca/xml';

  var access_key_id = '**************',
      secret_key = '**********************',
      associate_tag = '****************';

  var params = {
    Service: 'AWSECommerceService',
    Operation: 'ItemLookup',
    AWSAccessKeyId: access_key_id,
    AssociateTag: associate_tag,
    ItemId: '9780892131341', // Hardcoded an ISBN for testing
    SearchIndex: 'Books',
    IdType: 'ISBN',
    ResponseGroup: 'ItemAttributes, Images, Offers',
    Timestamp: new Date().toISOString()
  };

  //sort params by keys
  var canonical_query_string = Object.keys(params).sort();

  // urlencode
  canonical_query_string = canonical_query_string.map(function(key){
    return key + '=' + encodeURIComponent(params[key]);
  });

  // Generate canonical query
  canonical_query_string = canonical_query_string.join('&')

  var string_to_sign = 'GET\n' + endpoint + '\n' + uri + '\n' + canonical_query_string;

  var signature = Utilities.base64Encode(Utilities.computeHmacSha256Signature(string_to_sign, secret_key));
  var request = 'http://' + endpoint + uri + '?' + canonical_query_string + '&Signature=' + encodeURIComponent(signature);
  Logger.log(request)
  var response = UrlFetchApp.fetch(request, {muteHttpExceptions: true});

  var data = XmlService.parse(response);
  var elements = data.getRootElement().getChildren();

  Logger.log((elements));
  elements.forEach(function(e) { Logger.log(e) })
}

Logging elements gives me:

[[Element: <OperationRequest [Namespace: http://webservices.amazon.com/AWSECommerceService/2011-08-01]/>], [Element: <Items [Namespace: http://webservices.amazon.com/AWSECommerceService/2011-08-01]/>]]

elements.forEach(function(e) { Logger.log(e) }) outputs:

[18-02-11 20:36:41:785 PST] [Element: <OperationRequest [Namespace: http://webservices.amazon.com/AWSECommerceService/2011-08-01]/>]
[18-02-11 20:36:41:786 PST] [Element: <Items [Namespace: http://webservices.amazon.com/AWSECommerceService/2011-08-01]/>]

elements.length gives me 2.0

typeof(elements[0]) gives me object

Running elements[0] gives me:

[Element: <OperationRequest [Namespace: http://webservices.amazon.com/AWSECommerceService/2011-08-01]/>]

Here is the full XML response:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<OperationRequest>
<HTTPHeaders>
<Header Name="UserAgent" Value="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"/>
</HTTPHeaders>
<RequestId>10cc1aff-8ca6-4207-9f71-80f46eb8d5e6</RequestId>
<Arguments>
<Argument Name="AWSAccessKeyId" Value="**************"/>
<Argument Name="AssociateTag" Value="**************"/>
<Argument Name="IdType" Value="ISBN"/>
<Argument Name="ItemId" Value="9780892131341"/>
<Argument Name="Operation" Value="ItemLookup"/>
<Argument Name="ResponseGroup" Value="ItemAttributes, Images, Offers"/>
<Argument Name="SearchIndex" Value="Books"/>
<Argument Name="Service" Value="AWSECommerceService"/>
<Argument Name="Timestamp" Value="2018-02-12T04:07:56.358Z"/>
<Argument Name="Signature" Value="rhOiCu2p1O9hwyHVHOSGgdBrDmLgmybafy2F9bhahuU="/>
</Arguments>
<RequestProcessingTime>0.0927801110000000</RequestProcessingTime>
</OperationRequest>
<Items>
<Request>
<IsValid>True</IsValid>
<ItemLookupRequest>
<IdType>ISBN</IdType>
<ItemId>9780892131341</ItemId>
<ResponseGroup>ItemAttributes</ResponseGroup>
<ResponseGroup>Images</ResponseGroup>
<ResponseGroup>Offers</ResponseGroup>
<SearchIndex>Books</SearchIndex>
<VariationPage>All</VariationPage>
</ItemLookupRequest>
</Request>
<Item>
<ASIN>0892131349</ASIN>
<DetailPageURL>
https://www.amazon.com/Bhagavad-Gita-Paperback-Bhaktivedanta-Swami-Prabhupada/dp/0892131349?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=0892131349
</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Technical Details</Description>
<URL>
https://www.amazon.com/Bhagavad-Gita-Paperback-Bhaktivedanta-Swami-Prabhupada/dp/tech-data/0892131349?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Baby Registry</Description>
<URL>
https://www.amazon.com/gp/registry/baby/add-item.html?asin.0=0892131349&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wedding Registry</Description>
<URL>
https://www.amazon.com/gp/registry/wedding/add-item.html?asin.0=0892131349&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>
https://www.amazon.com/gp/registry/wishlist/add-item.html?asin.0=0892131349&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>
https://www.amazon.com/gp/pdp/taf/0892131349?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>
https://www.amazon.com/review/product/0892131349?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>
https://www.amazon.com/gp/offer-listing/0892131349?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</URL>
</ItemLink>
</ItemLinks>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">43</Width>
</SmallImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">92</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL.jpg
</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">287</Width>
</LargeImage>
<ImageSets>
<ImageSet Category="variant">
<SwatchImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/31zlupl4ZiL._SL30_.jpg
</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">22</Width>
</SwatchImage>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/31zlupl4ZiL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">56</Width>
</SmallImage>
<ThumbnailImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/31zlupl4ZiL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">56</Width>
</ThumbnailImage>
<TinyImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/31zlupl4ZiL._SL110_.jpg
</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">82</Width>
</TinyImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/31zlupl4ZiL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">120</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/31zlupl4ZiL.jpg
</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">375</Width>
</LargeImage>
</ImageSet>
<ImageSet Category="primary">
<SwatchImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL30_.jpg
</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">17</Width>
</SwatchImage>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">43</Width>
</SmallImage>
<ThumbnailImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">43</Width>
</ThumbnailImage>
<TinyImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL110_.jpg
</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">63</Width>
</TinyImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">92</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/51iixzFhJDL.jpg
</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">287</Width>
</LargeImage>
</ImageSet>
</ImageSets>
<ItemAttributes>
<Author>A. C. Bhaktivedanta Swami Prabhupada</Author>
<Binding>Mass Market Paperback</Binding>
<Brand>Bhaktivedanta Book Trust</Brand>
<EAN>9780892131341</EAN>
<EANList>
<EANListElement>9780892131341</EANListElement>
</EANList>
<Edition>De Luxe edition</Edition>
<Feature>Most popular book</Feature>
<Format>Deluxe Edition</Format>
<ISBN>0892131349</ISBN>
<ItemDimensions>
<Height Units="hundredths-inches">700</Height>
<Length Units="hundredths-inches">400</Length>
<Weight Units="Hundredths Pounds">95</Weight>
<Width Units="hundredths-inches">175</Width>
</ItemDimensions>
<Label>Bhaktivedanta Book Trust</Label>
<Languages>
<Language>
<Name>English</Name>
<Type>Published</Type>
</Language>
<Language>
<Name>Sanskrit</Name>
<Type>Original Language</Type>
</Language>
<Language>
<Name>English</Name>
<Type>Unknown</Type>
</Language>
</Languages>
<ListPrice>
<Amount>595</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$5.95</FormattedPrice>
</ListPrice>
<Manufacturer>Bhaktivedanta Book Trust</Manufacturer>
<MPN>colour illustrations</MPN>
<NumberOfItems>1</NumberOfItems>
<NumberOfPages>703</NumberOfPages>
<PackageDimensions>
<Height Units="hundredths-inches">140</Height>
<Length Units="hundredths-inches">700</Length>
<Weight Units="Hundredths Pounds">95</Weight>
<Width Units="hundredths-inches">420</Width>
</PackageDimensions>
<PackageQuantity>1</PackageQuantity>
<PartNumber>colour illustrations</PartNumber>
<ProductGroup>Book</ProductGroup>
<ProductTypeName>ABIS_BOOK</ProductTypeName>
<PublicationDate>1989-06-01</PublicationDate>
<Publisher>Bhaktivedanta Book Trust</Publisher>
<Studio>Bhaktivedanta Book Trust</Studio>
<Title>Bhagavad-Gita As It Is (Paperback)</Title>
</ItemAttributes>
<OfferSummary>
<LowestNewPrice>
<Amount>1</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$0.01</FormattedPrice>
</LowestNewPrice>
<LowestUsedPrice>
<Amount>10</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$0.10</FormattedPrice>
</LowestUsedPrice>
<LowestCollectiblePrice>
<Amount>495</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$4.95</FormattedPrice>
</LowestCollectiblePrice>
<TotalNew>150</TotalNew>
<TotalUsed>327</TotalUsed>
<TotalCollectible>6</TotalCollectible>
<TotalRefurbished>0</TotalRefurbished>
</OfferSummary>
<Offers>
<TotalOffers>1</TotalOffers>
<TotalOfferPages>1</TotalOfferPages>
<MoreOffersUrl>
https://www.amazon.com/gp/offer-listing/0892131349?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=0892131349
</MoreOffersUrl>
<Offer>
<OfferAttributes>
<Condition>New</Condition>
</OfferAttributes>
<OfferListing>
<OfferListingId>
RGJQzokPTIQv7ptj6VjeaQvVQ5EfYhv3JVqw7drNMVculYaURMxZeJ9Ve5%2FmikeH1e3Il4o1xokKJdpJbQpxcd1RG5lwjnydOJ%2FJjJBjtd0%3D
</OfferListingId>
<Price>
<Amount>595</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$5.95</FormattedPrice>
</Price>
<Availability>Usually ships in 24 hours</Availability>
<AvailabilityAttributes>
<AvailabilityType>now</AvailabilityType>
<MinimumHours>0</MinimumHours>
<MaximumHours>0</MaximumHours>
</AvailabilityAttributes>
<IsEligibleForSuperSaverShipping>1</IsEligibleForSuperSaverShipping>
<IsEligibleForPrime>1</IsEligibleForPrime>
</OfferListing>
</Offer>
</Offers>
</Item>
<Item>
<ASIN>B002J358V2</ASIN>
<DetailPageURL>
https://www.amazon.com/Bhagavad-Gita-Bhaktivedanta-Swami-Prabhupada-Author/dp/B002J358V2?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B002J358V2
</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Technical Details</Description>
<URL>
https://www.amazon.com/Bhagavad-Gita-Bhaktivedanta-Swami-Prabhupada-Author/dp/tech-data/B002J358V2?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Baby Registry</Description>
<URL>
https://www.amazon.com/gp/registry/baby/add-item.html?asin.0=B002J358V2&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wedding Registry</Description>
<URL>
https://www.amazon.com/gp/registry/wedding/add-item.html?asin.0=B002J358V2&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>
https://www.amazon.com/gp/registry/wishlist/add-item.html?asin.0=B002J358V2&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>
https://www.amazon.com/gp/pdp/taf/B002J358V2?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>
https://www.amazon.com/review/product/B002J358V2?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>
https://www.amazon.com/gp/offer-listing/B002J358V2?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B002J358V2
</URL>
</ItemLink>
</ItemLinks>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">43</Width>
</SmallImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">92</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL.jpg
</URL>
<Height Units="pixels">346</Height>
<Width Units="pixels">199</Width>
</LargeImage>
<ImageSets>
<ImageSet Category="variant">
<SwatchImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41J58-9dw7L._SL30_.jpg
</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">17</Width>
</SwatchImage>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41J58-9dw7L._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">42</Width>
</SmallImage>
<ThumbnailImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41J58-9dw7L._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">42</Width>
</ThumbnailImage>
<TinyImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41J58-9dw7L._SL110_.jpg
</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">62</Width>
</TinyImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41J58-9dw7L._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">90</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41J58-9dw7L.jpg
</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">281</Width>
</LargeImage>
</ImageSet>
<ImageSet Category="primary">
<SwatchImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL30_.jpg
</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">17</Width>
</SwatchImage>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">43</Width>
</SmallImage>
<ThumbnailImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">43</Width>
</ThumbnailImage>
<TinyImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL110_.jpg
</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">63</Width>
</TinyImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">92</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/41CJZYo14rL.jpg
</URL>
<Height Units="pixels">346</Height>
<Width Units="pixels">199</Width>
</LargeImage>
</ImageSet>
</ImageSets>
<ItemAttributes>
<Author>
A.C. Bhaktivedanta Swami; A.C. Bhaktivedanta Swami Prabhupada (Author) Prabhupada
</Author>
<Binding>Mass Market Paperback</Binding>
<EAN>9780892131341</EAN>
<EANList>
<EANListElement>9780892131341</EANListElement>
</EANList>
<Edition>2nd Edition</Edition>
<ISBN>0892131349</ISBN>
<Label>
The Bhaktivedanta Book Trust/ International Society for Krishna Consciousness
</Label>
<Manufacturer>
The Bhaktivedanta Book Trust/ International Society for Krishna Consciousness
</Manufacturer>
<NumberOfItems>1</NumberOfItems>
<PackageDimensions>
<Height Units="hundredths-inches">94</Height>
<Length Units="hundredths-inches">676</Length>
<Weight Units="Hundredths Pounds">40</Weight>
<Width Units="hundredths-inches">420</Width>
</PackageDimensions>
<ProductGroup>Book</ProductGroup>
<ProductTypeName>BOOKS_1973_AND_LATER</ProductTypeName>
<PublicationDate>1983</PublicationDate>
<Publisher>
The Bhaktivedanta Book Trust/ International Society for Krishna Consciousness
</Publisher>
<Studio>
The Bhaktivedanta Book Trust/ International Society for Krishna Consciousness
</Studio>
<Title>Bhagavad-Gita As It Is</Title>
</ItemAttributes>
<OfferSummary>
<LowestNewPrice>
<Amount>499</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$4.99</FormattedPrice>
</LowestNewPrice>
<LowestUsedPrice>
<Amount>394</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$3.94</FormattedPrice>
</LowestUsedPrice>
<TotalNew>11</TotalNew>
<TotalUsed>17</TotalUsed>
<TotalCollectible>0</TotalCollectible>
<TotalRefurbished>0</TotalRefurbished>
</OfferSummary>
<Offers>
<TotalOffers>0</TotalOffers>
<TotalOfferPages>0</TotalOfferPages>
<MoreOffersUrl>0</MoreOffersUrl>
</Offers>
</Item>
<Item>
<ASIN>B003WM5JQI</ASIN>
<DetailPageURL>
https://www.amazon.com/Bhagavad-Gita-As-C-Bhaktivedanta/dp/B003WM5JQI?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B003WM5JQI
</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Technical Details</Description>
<URL>
https://www.amazon.com/Bhagavad-Gita-As-C-Bhaktivedanta/dp/tech-data/B003WM5JQI?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Baby Registry</Description>
<URL>
https://www.amazon.com/gp/registry/baby/add-item.html?asin.0=B003WM5JQI&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wedding Registry</Description>
<URL>
https://www.amazon.com/gp/registry/wedding/add-item.html?asin.0=B003WM5JQI&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>
https://www.amazon.com/gp/registry/wishlist/add-item.html?asin.0=B003WM5JQI&SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>
https://www.amazon.com/gp/pdp/taf/B003WM5JQI?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>
https://www.amazon.com/review/product/B003WM5JQI?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>
https://www.amazon.com/gp/offer-listing/B003WM5JQI?SubscriptionId=AKIAJN4W3TYVBZX4VOHA&tag=brucecommerce-20&linkCode=xm2&camp=2025&creative=386001&creativeASIN=B003WM5JQI
</URL>
</ItemLink>
</ItemLinks>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">44</Width>
</SmallImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">94</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL.jpg
</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">295</Width>
</LargeImage>
<ImageSets>
<ImageSet Category="primary">
<SwatchImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL30_.jpg
</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">18</Width>
</SwatchImage>
<SmallImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">44</Width>
</SmallImage>
<ThumbnailImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL75_.jpg
</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">44</Width>
</ThumbnailImage>
<TinyImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL110_.jpg
</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">65</Width>
</TinyImage>
<MediumImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL._SL160_.jpg
</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">94</Width>
</MediumImage>
<LargeImage>
<URL>
https://images-na.ssl-images-amazon.com/images/I/5107miyFvWL.jpg
</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">295</Width>
</LargeImage>
</ImageSet>
</ImageSets>
<ItemAttributes>
<Author>A. C. Bhaktivedanta</Author>
<Binding>Paperback</Binding>
<EAN>9780892131341</EAN>
<EANList>
<EANListElement>9780892131341</EANListElement>
</EANList>
<ISBN>0892131349</ISBN>
<Label>Bhaktivedanta Book Trust, Australia</Label>
<Languages>
<Language>
<Name>English</Name>
<Type>Published</Type>
</Language>
<Language>
<Name>English</Name>
<Type>Unknown</Type>
</Language>
</Languages>
<Manufacturer>Bhaktivedanta Book Trust, Australia</Manufacturer>
<NumberOfItems>1</NumberOfItems>
<NumberOfPages>642</NumberOfPages>
<PackageDimensions>
<Height Units="hundredths-inches">130</Height>
<Length Units="hundredths-inches">680</Length>
<Weight Units="Hundredths Pounds">75</Weight>
<Width Units="hundredths-inches">420</Width>
</PackageDimensions>
<ProductGroup>Book</ProductGroup>
<ProductTypeName>BOOKS_1973_AND_LATER</ProductTypeName>
<PublicationDate>1985</PublicationDate>
<Publisher>Bhaktivedanta Book Trust, Australia</Publisher>
<SKU>6877628</SKU>
<Studio>Bhaktivedanta Book Trust, Australia</Studio>
<Title>Bhagavad-Gita As It Is</Title>
</ItemAttributes>
<OfferSummary>
<LowestNewPrice>
<Amount>500</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$5.00</FormattedPrice>
</LowestNewPrice>
<LowestUsedPrice>
<Amount>210</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$2.10</FormattedPrice>
</LowestUsedPrice>
<LowestCollectiblePrice>
<Amount>2400</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$24.00</FormattedPrice>
</LowestCollectiblePrice>
<TotalNew>8</TotalNew>
<TotalUsed>29</TotalUsed>
<TotalCollectible>2</TotalCollectible>
<TotalRefurbished>0</TotalRefurbished>
</OfferSummary>
<Offers>
<TotalOffers>0</TotalOffers>
<TotalOfferPages>0</TotalOfferPages>
<MoreOffersUrl>0</MoreOffersUrl>
</Offers>
</Item>
</Items>
</ItemLookupResponse>

Sorry the XML formatting got messed up while copy/pasting, but I think it'll do.

I can't seem to traverse the document the way I would expect to. If someone could help me understand what I'm missing, that would be greatly appreciated, thanks!

EDIT:

I managed to get the ASIN number:

var item1 = items[1].asElement();
var item1_children = item1.getChildren();
var item1_asin = item1_children[0].getAllContent();

Outputs:

[18-02-11 22:07:33:500 PST] [0892131349]

When I try to run getAttribute('ASIN') or getChild('ASIN') I get back null

How can I write this so that I can utilize the getAttribute(String name) or getChild(String name) methods?