I have xml file of the client shared via a url and I want to download only the first 10 entries from the file instead of downloading the whole file.
I know how to download a xml file in python, but instead of downloading the whole file, I just want to download first 10 entries of the xml.
import requests
URL = "http://clientfeed.com/feed/feed.xml"
response = requests.get(URL,stream=True)
But here I don't know how to proceed to download only 10 entries from the file
Sample Tree node of a xml
/products ---Root element
/products/product --Repeat element
/products/product/id
/products/product/name
/products/product/producturl
/products/product/bigimage
/products/product/price
/products/product/instock
/products/product/category
Here first 10 entries of /products/product needs to be downloaded instead of the whole file.
Sample xml file having first four entries
<?xml version="1.0"?>
<products>
<product>
<id>1212</id>
<name>product name</name>
<producturl>product url</producturl>
<bigimage>image url</bigimage>
<price>11323</price>
<instock>yes</instock>
<category>cate</category>
</product>
<product>
<id>35345</id>
<name>product name</name>
<producturl>product url</producturl>
<bigimage>image url</bigimage>
<price>11323</price>
<instock>yes</instock>
<category>cate</category>
</product>
<product>
<id>7656756</id>
<name>product name</name>
<producturl>product url</producturl>
<bigimage>image url</bigimage>
<price>11323</price>
<instock>yes</instock>
<category>cate</category>
</product>
<product>
<id>575686786</id>
<name>product name</name>
<producturl>product url</producturl>
<bigimage>image url</bigimage>
<price>11323</price>
<instock>yes</instock>
<category>cate</category>
</product>
</products>
Can someone guide me here how to achieve this?
Thanks in advance