title: How to use lxml to grab specific parts of an XML document?
body: <p>I am using Amazon's API to receive information about books. I am trying to use lxml to extract specific parts of the XMl document that are needed for my application.
  I am not really sure how to use lxml, though.
  This is as far as I have gotten:</p>
  
  <pre><code>root = etree.XML(response)
  </code></pre>
  
  <p>To create a etree object for the XML document.</p>
  
  <p>Here is what the XML document looks like:
  <a href="http://pastebin.com/GziDkf1a" rel="nofollow">http://pastebin.com/GziDkf1a</a>
  There are actually multiple "Items", but I only pasted one of them to give you a specific example.
  For each item, I want to extract the title and ISBN. How do I do that with the etree object that I have?</p>
  
  <pre><code>&lt;ItemSearchResponse&gt;&lt;Items&gt;&lt;Item&gt;&lt;ItemAttributes&gt;&lt;Title&gt;I want this info&lt;/Title&gt;&lt;/ItemAttributes&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/ItemSearchResponse
  
  &lt;ItemSearchResponse&gt;&lt;Items&gt;&lt;Item&gt;&lt;ItemAttributes&gt;&lt;ISBN&gt;And I want this info&lt;/ISBN&gt;&lt;/ItemAttributes&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/ItemSearchResponse
  </code></pre>
  
  <p>Basically, I do not know how to traverse the tree using my etree object, and I want to learn how.</p>
  
  <p><strong>Edit 1:</strong>
  I am trying the following code:</p>
  
  <pre><code>tree = etree.fromstring(response)
  for item in tree.iterfind(".//"+AMAZON_NS+"ItemAttributes"):
      print(item)
      print(item.items()) # Apparently, there is nothing in item.items()
      for key, value in item.items():
          print(key)
          print(value)
  </code></pre>
  
  <p>But I get the following output:
  <a href="http://dpaste.com/287496/" rel="nofollow">http://dpaste.com/287496/</a></p>
  
  <p>I added the print(item.items()), and it just seems to be an empty list. Each item is an Element, though, but for some reason, they have no items.</p>
  
  <p>Edit 2:
  I can use the following code to get the information I want, but it seems like lxml must have an easier way... (this way doesn't seem very efficient):</p>
  
  <pre><code>for item in tree.iterfind(".//"+AMAZON_NS+"ItemAttributes"):
      title_text = ""
      author_text = ""
      isbn_text = ""
      for isbn in item.iterfind(".//"+AMAZON_NS+"ISBN"):
          isbn_text = isbn.text
      for title in item.iterfind(".//"+AMAZON_NS+"Title"):
          title_text = title.text
      for author in item.iterfind(".//"+AMAZON_NS+"Author"):
          author_text = author.text
      print(title_text + " by " + author_text + " has ISBN: " + isbn_text)
  </code></pre>