How To Limit The Scope Of Element Extraction Between The Start And End Tag Of A Particular Xml Element Using Xpath In Python?
I have an RDF/XML Element and would like to find out all the elements between the start and end of a particular tag. How could I do that? for example :
Solution 1:
Parsing the XML File using XPath seemed to be a really bad idea for the question. Rdflib makes it very easy.
import rdflib
from rdflib import Graph
from rdflib.namespace import Namespace
BASE = Namespace('http://example.org/')
graph = rdflib.Graph()
graph.parse('rdf.xml', format='xml', publicID=BASE)
for p,o in graph[BASE['#_0526B48408F744919E7C03672FCD0D71']]:
print(p, o)
Post a Comment for "How To Limit The Scope Of Element Extraction Between The Start And End Tag Of A Particular Xml Element Using Xpath In Python?"