Con il framework python lxml.etree
, è più efficiente analizzare xml direttamente da un collegamento a un file xml online o è meglio dire, utilizzare un framework diverso (come urllib2
), per restituire una stringa e quindi analizzare da quella ? O non fa alcuna differenza?Python lxml.etree - È più efficace analizzare XML da string o direttamente dal link?
Metodo 1 - Parse direttamente dal collegamento
from lxml import etree as ET
parsed = ET.parse(url_link)
Metodo 2 - Parse da stringa
from lxml import etree as ET
import urllib2
xml_string = urllib2.urlopen(url_link).read()
parsed = ET.parse.fromstring(xml_string)
# note: I do not have access to python
# at the moment, so not sure whether
# the .fromstring() function is correct
O c'è un metodo più efficiente di uno di questi, ad esempio salvare l'xml in un file .xml sul desktop, quindi analizzare da quelli?