from lxml import etree as E class DenyExternal(E.Resolver): def resolve(self, url, public_id, context): raise ValueError("External resources are disabled") def parse(text): if "" root = parse(source) ns = {"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "seed": "urn:bhylu:seed:"} print(root.xpath("string(rdf:Description/@rdf:about)", namespaces=ns)) print(root.xpath("string(rdf:Description/seed:category/@rdf:resource)", namespaces=ns))