def recentlyAdded(servercfg): logger = logging.getLogger(__name__) url = "http://apollo.ayercraft.net:32400/library/sections/7/recentlyAdded" response = getURL(url) if pArgs.xmlparser == "lxml": xmlContent = letree.fromstring(response.text.encode('utf8')) parser = letree.XMLParser(ns_clean=True) tree = letree.parse(StringIO(xmlContent), parser) elif pArgs.xmlparser == "xml": xmlContent = xetree.ElementTree.fromstring( response.text.encode('utf8')) parser = xetree.XMLParser(ns_clean=True) tree = xetree.parse(StringIO(xmlContent), parser) for element in xmlContent.iter(): if element.tag == "Directory": mptitle = element.get('parentTitle') mstitle = element.get('title') mtype = element.get('type') logger.info("Title: %s\tType: %s\tSubTitle: %s" % (mptitle, mstitle, mtype)) if element.tag == "Video": vtype = element.get('type') if vtype == "episode": vptitle = str( element.get('grandparentTitle')).encode('utf-8').strip() vseason = str( element.get('parentIndex')).encode('utf-8').strip() vepisode = str(element.get('index')).encode('utf-8').strip() vetitle = unicode(element.get('title')).encode( 'ascii', 'replace') logger.info("Title: %s\tSeason: %s\tEpisode: %s\tTitle: %s" % (vptitle, vseason, vepisode, vetitle))
def load(fp): """ :param fp: :return Rpm: """ parser = etree.XMLParser(target=RpmParser()) return etree.parse(fp.read(), parser)
file_in = "osim-rl/osim/models/gait9dof18musc.osim" file_out = "mujoco_gait9dof18musc.xml" import xml.etree from lxml import etree parser = etree.XMLParser(recover=True) e = etree.fromstring(xmlstring, parser=parser) e = xml.etree.ElementTree.parse('thefile.xml').getroot()
def setUp(self): self.parser = etree.XMLParser(remove_blank_text=True) self.tree = etree.parse('tests/instruments/companies.xml', parser=self.parser).getroot()
def setUp(self): self.parser = etree.XMLParser(remove_blank_text=True)
def prettyPrintXml(self, ): assert self.xmlFile is not None parser = etree.XMLParser(resolve_entities=False, strip_cdata=False) document = etree.parse(self.xmlFile, parser) document.write(self.xmlFile, pretty_print=True, encoding='utf-8')