xml-namespaces

Parse XML with namespaces in python

Parse XML with namespaces in python Question: I hope you are doing well. I really need your help on this one, I´ve been working with XML lately but I came across this XML with Namespaces that I don´t understand. I want to extract the values of the response but I don´t know how to do …

Total answers: 2

how to query xml data with namespaces using xpath in python

how to query xml data with namespaces using xpath in python Question: I am trying to apply an XPath query to XML data which has namespaces using the following code: from lxml import etree from io import StringIO xml = ”’ <gpx creator="udos" version="1.1" for element in tree.xpath(expr, namespaces=ns): print(element.text) I expect the following output …

Total answers: 1

Parsing XML with namespace in Python via 'ElementTree'

Parsing XML with namespace in Python via 'ElementTree' Question: I have the following XML which I want to parse using Python’s ElementTree: <rdf:RDF xml_base=”http://dbpedia.org/ontology/” > <owl:Class rdf_about=”http://dbpedia.org/ontology/BasketballLeague”> <rdfs:label xml_lang=”en”>basketball league</rdfs:label> <rdfs:comment xml_lang=”en”> a group of sports teams that compete against each other in Basketball </rdfs:comment> </owl:Class> </rdf:RDF> I want to find all owl:Class tags and …

Total answers: 7

python : lxml xpath tag name with colon

python : lxml xpath tag name with colon Question: i have to parse some feed, but one of the element (tag) is with colon <dc:creator>leemore23</dc:creator> how can i parse it using lxml? so i have done it in this way r = requests.get(‘http://www.site.com/feed/’) foo = (r.content).replace(“dc:creator”,”dc”) tree = lxml.etree.fromstring(foo) for article_node in tree.xpath(‘//item’): data[‘dc’] = …

Total answers: 2

How do I use xml namespaces with find/findall in lxml?

How do I use xml namespaces with find/findall in lxml? Question: I’m trying to parse content in an OpenOffice ODS spreadsheet. The ods format is essentially just a zipfile with a number of documents. The content of the spreadsheet is stored in ‘content.xml’. import zipfile from lxml import etree zf = zipfile.ZipFile(‘spreadsheet.ods’) root = etree.parse(zf.open(‘content.xml’)) …

Total answers: 4

How can I access namespaced XML elements using BeautifulSoup?

How can I access namespaced XML elements using BeautifulSoup? Question: I have an XML document which reads like this: <xml> <web:Web> <web:Total>4000</web:Total> <web:Offset>0</web:Offset> </web:Web> </xml> my question is how do I access them using a library like BeautifulSoup in python? xmlDom.web[“Web”].Total ? does not work? Asked By: demos || Source Answers: BeautifulSoup isn’t a DOM …

Total answers: 5