[Fixed]-Error reading file '/media/xml/example.xml': failed to load external entity "/media/xml/example.xml"

1๐Ÿ‘

โœ…

I recommend you Beautifulsoup, it is so cool and convinient to use:

dir = '/'.join([settings.BASE_DIR, 'media', 'xml/example.xml'])
abs_path = os.path.realpath(dir)
soup = BeautifulSoup(open(abs_path)) #<-- here you can now read/search thru xml file

for row in soup.find_all('row'):
    print row.find('name').text

if your xml looks like:

<?xml version='1.0' encoding='us-ascii'?>
<root>
   <row>
     <name>Wake up to BeautifulSoup!</name>
   </row>
</root>

you will get:

Wake up to BeautifulSoup!

the docs is here

๐Ÿ‘คdoniyor

Leave a comment