title: How do I get an attribute using the 'amazon-ecs' gem?
body: <p>I am using <a href="https://github.com/jugend/amazon-ecs" rel="nofollow noreferrer">Amazon Product Advertising API (amazon-ecs)</a> gem, but I am using the <code>item_lookup</code> method instead of <code>item_search</code>, which is the only one documented.</p>
  
  <p>I am looking to return the item <code>TradeInValue</code> but I am confused as to how to do that. It is clearly being returned, but I am not sure how to parse it.</p>
  
  <p>This is the call:  </p>
  
  <pre><code>Amazon::Ecs.item_lookup('9780521153348', :response_group =&gt; 'ItemAttributes', :id_type =&gt; 'ISBN', :search_index =&gt; 'Books')
  </code></pre>
  
  <p>And this is the return, which I am not sure what to do with. The methods in amazon-ecs don't seem to work for <code>item_lookup</code> and XPath isn't working either:</p>
  
  <pre><code>#&lt;Amazon::Ecs::Response:0x007ff3325250d0 @doc=#&lt;Nokogiri::XML::Document:0x3ff9992927a0 name="document" children=[#&lt;Nokogiri::XML::Element:0x3ff997067414 name="ItemLookupResponse" children=[#&lt;Nokogiri::XML::Element:0x3ff99706b924 name="OperationRequest" children=[#&lt;Nokogiri::XML::Element:0x3ff99706b474 name="HTTPHeaders" children=[#&lt;Nokogiri::XML::Element:0x3ff99706f470 name="Header" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff99706f0ec name="Name" value="UserAgent"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff99706f074 name="Value" value="Ruby"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9970760cc name="RequestId" children=[#&lt;Nokogiri::XML::Text:0x3ff999296468 "053626d3-e3cd-47d2-bc8b-7ac6a0c5f6d2"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99929f6f8 name="Arguments" children=[#&lt;Nokogiri::XML::Element:0x3ff9992a3bb8 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992a3960 name="Name" value="Operation"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992a3938 name="Value" value="ItemLookup"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992a73f8 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992a7204 name="Name" value="Signature"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992a7010 name="Value" value="IMd3D0DGgAcaLR6XcuObzdAgFbOya7mbIRtZFbNijVA="&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992ab41c name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992ab2dc name="Name" value="AssociateTag"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992ab2c8 name="Value" value="textscom-20"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992af774 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992af6ac name="Name" value="ItemId"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992af698 name="Value" value="9780521153348"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992b0c3c name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992b0b4c name="Name" value="IdType"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992b0b10 name="Value" value="ISBN"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992b7794 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992b7578 name="Name" value="AWSAccessKeyId"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992b7550 name="Value" value="AKIAJLOCEGWTFXZKXLEQ"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992b2244 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992b208c name="Name" value="Timestamp"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992b2064 name="Value" value="2013-05-07T17:46:35Z"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992bffc0 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992bff20 name="Name" value="ResponseGroup"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992bff0c name="Value" value="ItemAttributes"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992be1e8 name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992c38c8 name="Name" value="SearchIndex"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992c3a30 name="Value" value="Books"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992ca95c name="Argument" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9992ca344 name="Name" value="Service"&gt;, #&lt;Nokogiri::XML::Attr:0x3ff9992ca2a4 name="Value" value="AWSECommerceService"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992d3d7c name="RequestProcessingTime" children=[#&lt;Nokogiri::XML::Text:0x3ff9992d382c "0.0289960000000000"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992d7eb8 name="Items" children=[#&lt;Nokogiri::XML::Element:0x3ff9992d7148 name="Request" children=[#&lt;Nokogiri::XML::Element:0x3ff9992d6900 name="IsValid" children=[#&lt;Nokogiri::XML::Text:0x3ff9992dae10 "True"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992da758 name="ItemLookupRequest" children=[#&lt;Nokogiri::XML::Element:0x3ff9992df884 name="IdType" children=[#&lt;Nokogiri::XML::Text:0x3ff9992df014 "ISBN"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9992de678 name="ItemId" children=[#&lt;Nokogiri::XML::Text:0x3ff9992e2e1c "9780521153348"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983a5580 name="ResponseGroup" children=[#&lt;Nokogiri::XML::Text:0x3ff9983a59b8 "ItemAttributes"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983a510c name="SearchIndex" children=[#&lt;Nokogiri::XML::Text:0x3ff9983a43c4 "Books"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983a925c name="VariationPage" children=[#&lt;Nokogiri::XML::Text:0x3ff9983a8d0c "All"&gt;]&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983a8244 name="Item" children=[#&lt;Nokogiri::XML::Element:0x3ff9983add70 name="ASIN" children=[#&lt;Nokogiri::XML::Text:0x3ff9983ad6f4 "0521153344"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983acc04 name="DetailPageURL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983ac4d4 "http://www.amazon.com/Turgot-Progress-Sociology-Economics-Philosophical/dp/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0521153344"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983b1768 name="ItemLinks" children=[#&lt;Nokogiri::XML::Element:0x3ff9983b1024 name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983b0a20 name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983b028c "Technical Details"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983b5b60 name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983b5638 "http://www.amazon.com/Turgot-Progress-Sociology-Economics-Philosophical/dp/tech-data/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983b5034 name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983b4a58 name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983b46d4 "Add To Baby Registry"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983b406c name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983b9ad0 "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983b95d0 name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983b9080 name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983b8cd4 "Add To Wedding Registry"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983b8a2c name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983b834c "http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983bcff0 name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983bc49c name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983bc0f0 "Add To Wishlist"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983c1b40 name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983c158c "http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983c01dc name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983c5da8 name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983c595c "Tell A Friend"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983c5358 name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983c4674 "http://www.amazon.com/gp/pdp/taf/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983c9750 name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983c8828 name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983cc888 "All Customer Reviews"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983d1f18 name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983d19c8 "http://www.amazon.com/review/product/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983d152c name="ItemLink" children=[#&lt;Nokogiri::XML::Element:0x3ff9983d107c name="Description" children=[#&lt;Nokogiri::XML::Text:0x3ff9983d02d0 "All Offers"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983d5730 name="URL" children=[#&lt;Nokogiri::XML::Text:0x3ff9983d4e48 "http://www.amazon.com/gp/offer-listing/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344"&gt;]&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983dd00c name="ItemAttributes" children=[#&lt;Nokogiri::XML::Element:0x3ff9983dc33c name="Author" children=[#&lt;Nokogiri::XML::Text:0x3ff9983e1364 "Ronald L. Meek"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983e0af4 name="Binding" children=[#&lt;Nokogiri::XML::Text:0x3ff9983e04a0 "Paperback"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983e0068 name="EAN" children=[#&lt;Nokogiri::XML::Text:0x3ff9983e5c34 "9780521153348"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983e5270 name="EANList" children=[#&lt;Nokogiri::XML::Element:0x3ff9983e4424 name="EANListElement" children=[#&lt;Nokogiri::XML::Text:0x3ff9983d7c60 "9780521153348"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983d7724 name="ISBN" children=[#&lt;Nokogiri::XML::Text:0x3ff9983d7120 "0521153344"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983d6cc0 name="IsEligibleForTradeIn" children=[#&lt;Nokogiri::XML::Text:0x3ff9983d6130 "1"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983d99c0 name="ItemDimensions" children=[#&lt;Nokogiri::XML::Element:0x3ff9983d963c name="Height" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9983d959c name="Units" value="hundredths-inches"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff9983d83cc "902"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983ed7a4 name="Length" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9983ed448 name="Units" value="hundredths-inches"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff9983f3244 "598"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983f290c name="Weight" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9983f26f0 name="Units" value="hundredths-pounds"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff9983e93c0 "64"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983e8f38 name="Width" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9983e8e34 name="Units" value="hundredths-inches"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff9983efa2c "43"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983ef144 name="Label" children=[#&lt;Nokogiri::XML::Text:0x3ff9983eecbc "Cambridge University Press"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983ee988 name="Languages" children=[#&lt;Nokogiri::XML::Element:0x3ff9983ee410 name="Language" children=[#&lt;Nokogiri::XML::Element:0x3ff99a80009c name="Name" children=[#&lt;Nokogiri::XML::Text:0x3ff99a801a14 "English"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a8010f0 name="Type" children=[#&lt;Nokogiri::XML::Text:0x3ff99a800948 "Unknown"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a800574 name="Language" children=[#&lt;Nokogiri::XML::Element:0x3ff99a8002b8 name="Name" children=[#&lt;Nokogiri::XML::Text:0x3ff99a80419c "English"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a805484 name="Type" children=[#&lt;Nokogiri::XML::Text:0x3ff99a804b10 "Original Language"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a804070 name="Language" children=[#&lt;Nokogiri::XML::Element:0x3ff99a808d64 name="Name" children=[#&lt;Nokogiri::XML::Text:0x3ff99a80d6d4 "English"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a80c680 name="Type" children=[#&lt;Nokogiri::XML::Text:0x3ff99a8110a4 "Published"&gt;]&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a8157a8 name="ListPrice" children=[#&lt;Nokogiri::XML::Element:0x3ff99a8142cc name="Amount" children=[#&lt;Nokogiri::XML::Text:0x3ff99a819358 "2899"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a818d04 name="CurrencyCode" children=[#&lt;Nokogiri::XML::Text:0x3ff99a818764 "USD"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a81c8a0 name="FormattedPrice" children=[#&lt;Nokogiri::XML::Text:0x3ff99a81d534 "$28.99"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a81ccb0 name="Manufacturer" children=[#&lt;Nokogiri::XML::Text:0x3ff99a81c648 "Cambridge University Press"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a81c2d8 name="NumberOfItems" children=[#&lt;Nokogiri::XML::Text:0x3ff99a821cec "1"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a821580 name="NumberOfPages" children=[#&lt;Nokogiri::XML::Text:0x3ff99a82043c "194"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a825bbc name="PackageDimensions" children=[#&lt;Nokogiri::XML::Element:0x3ff99a824cd0 name="Height" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff99a824b68 name="Units" value="hundredths-inches"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff99a824168 "63"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a829d98 name="Length" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff99a829d20 name="Units" value="hundredths-inches"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff99a828eac "890"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff99a828c68 name="Weight" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff99a828b8c name="Units" value="hundredths-pounds"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff99a828074 "66"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9983f69d0 name="Width" attributes=[#&lt;Nokogiri::XML::Attr:0x3ff9983f68f4 name="Units" value="hundredths-inches"&gt;] children=[#&lt;Nokogiri::XML::Text:0x3ff997c6340c "598"&gt;]&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff997c62cf0 name="ProductGroup" children=[#&lt;Nokogiri::XML::Text:0x3ff997c623b8 "Book"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9961e1d2c name="ProductTypeName" children=[#&lt;Nokogiri::XML::Text:0x3ff9961e0e40 "ABIS_BOOK"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9961e0508 name="PublicationDate" children=[#&lt;Nokogiri::XML::Text:0x3ff9961e7b28 "2010-06-10"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9961e75c4 name="Publisher" children=[#&lt;Nokogiri::XML::Text:0x3ff9961e727c "Cambridge University Press"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9961e70b0 name="SKU" children=[#&lt;Nokogiri::XML::Text:0x3ff9961e6bc4 "Y9780521153348"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9961e682c name="Studio" children=[#&lt;Nokogiri::XML::Text:0x3ff9961ebc64 "Cambridge University Press"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff9961ea120 name="Title" children=[#&lt;Nokogiri::XML::Text:0x3ff996f67ac8 "Turgot on Progress, Sociology and Economics: A Philosophical Review of the Successive Advances of the Human Mind on Universal History Reflections on ... in the History and Theory of Politics)"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff996f676cc name="TradeInValue" children=[#&lt;Nokogiri::XML::Element:0x3ff996f67028 name="Amount" children=[#&lt;Nokogiri::XML::Text:0x3ff996f66ca4 "310"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff996f669d4 name="CurrencyCode" children=[#&lt;Nokogiri::XML::Text:0x3ff996f663a8 "USD"&gt;]&gt;, #&lt;Nokogiri::XML::Element:0x3ff996fadbb8 name="FormattedPrice" children=[#&lt;Nokogiri::XML::Text:0x3ff996fad014 "$3.10"&gt;]&gt;]&gt;]&gt;]&gt;]&gt;]&gt;]&gt;&gt;
  </code></pre>