title: Using lxml xpath to parse xml file
body: <p>I'm using lxml XPath to parse the following xml file</p>
  
  <pre><code>&lt;urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
      xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"&gt;
      &lt;url&gt;
          &lt;loc&gt;
      https://www.reuters.com/article/us-campbellsoup-thirdpoint/campbell-soup-nears-deal-with-third-point-to-end-board-challenge-sources-idUSKCN1NU11I
      &lt;/loc&gt;
          &lt;image:image&gt;
              &lt;image:loc&gt;
      https://www.reuters.com/resources/r/?m=02&amp;d=20181126&amp;t=2&amp;i=1328589868&amp;w=&amp;fh=&amp;fw=&amp;ll=460&amp;pl=300&amp;r=LYNXNPEEAO0WM
      &lt;/image:loc&gt;
          &lt;/image:image&gt;
          &lt;news:news&gt;
              &lt;news:publication&gt;
                  &lt;news:name&gt;Reuters&lt;/news:name&gt;
                  &lt;news:language&gt;eng&lt;/news:language&gt;
              &lt;/news:publication&gt;
              &lt;news:publication_date&gt;2018-11-26T02:55:00+00:00&lt;/news:publication_date&gt;
              &lt;news:title&gt;
      Campbell Soup nears deal with Third Point to end board challenge: sources
      &lt;/news:title&gt;
              &lt;news:keywords&gt;Headlines,Business, Industry&lt;/news:keywords&gt;
              &lt;news:stock_tickers&gt;NYSE:CPB&lt;/news:stock_tickers&gt;
          &lt;/news:news&gt;
      &lt;/url&gt;
  &lt;/urlset&gt;
  </code></pre>
  
  <p>Python code sample</p>
  
  <pre><code>import lxml.etree
  import lxml.html
  import requests
  
  def main():
      r = requests.get("https://www.reuters.com/sitemap_news_index1.xml")
  
      namespace = "http://www.google.com/schemas/sitemap-news/0.9"
      root = lxml.etree.fromstring(r.content)
  
  
      records = root.xpath('//news:title', namespaces = {"news": "http://www.google.com/schemas/sitemap-news/0.9"})
      for record in records:
          print(record.text)
  
  
      records = root.xpath('//sitemap:loc', namespaces = {"sitemap": "http://www.sitemaps.org/schemas/sitemap/0.9"})
      for record in records:
          print(record.text)
  
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>Currently, I'm XPath to get all <em>URL</em> and <em>title</em>, but this is not what I want because I don't know which URL belongs to which title. My question is how to get each <code>&lt;url&gt;</code>, then loop each <code>&lt;url&gt;</code> as item to get corresponding <code>&lt;loc&gt;</code> and <code>&lt;news:keywords&gt;</code> etc. Thanks!</p>
  
  <p>Edit:
  Expecting output</p>
  
  <pre><code>foreach &lt;url&gt;
        get &lt;loc&gt;
        get &lt;news:publication_date&gt;
        get &lt;news:title&gt;
  </code></pre>