我有以下XML,我想使用Python的ElementTree解析:
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns="http://dbpedia.org/ontology/">
basketball league
a group of sports teams that compete against each other
in Basketball
我想找到所有的owl:Class标签,然后提取其中所有rdfs:label实例的值。我使用下面的代码:
tree = ET.parse("filename")
root = tree.getroot()
root.findall('owl:Class')
由于命名空间,我得到以下错误。
SyntaxError: prefix 'owl' not found in prefix map
请让我知道如何改变代码找到所有的猫头鹰:类标签。