How can I parse an external XML file with django/python
I've done some research on trying to parse an XML file from 开发者_如何学JAVAanother web server and came across something called minidom.
I've tried implementing this in my view.py file:
from xml.dom import minidom
import models
def test(request):
data={}
doc=minidom.parse("http://www.someotherdomain.com/XML.aspx?id=27550&limit=100")
The problem I'm running into is I get the error Exception Value: [Errno 2] No such file or directory: 'http://www.someotherdomain.com/XML.aspx?id=27550&limit=100'
I haven't been able to find out if you can use minidom on an external document or if it's only for documents located on the same server.
If this is not possible or is not the ideal solution?
Apparently minidom cannot parse URLs. You have to do
import urllib2
doc = urllib2.urlopen(your_url)
parsed = minidom.parse(doc)
精彩评论