[xml] [python] DOM object from file with parsing options
- From: Nicolas Mazziotta <nicolas mazziotta skynet be>
- To: xml gnome org
- Subject: [xml] [python] DOM object from file with parsing options
- Date: Mon, 30 Jun 2008 16:01:26 +0200
Hello,
I am trying to create a DOM object from a file and to navigate it with xpath
queries. I have to turn off entity declaration and therefore use parser
options. It means that I cannot use the parseFile() method.
When I create the parser, configure it and run it on my test.xml file, it
parses well, but xpath queries all return nothing, except for queries that
use no tag name ("/", "/*/*" and the like). Any idea about what goes wrong?
#############
PARSER_OPTIONS = libxml2.XML_CHECK_NOT_ENTITY_DECL
parser=libxml2.createFileParserCtxt("test.xml")
parser.validate(0)
parser.ctxtUseOptions(PARSER_OPTIONS)
parser.parseDocument()
xmlDoc = parser.doc()
ctxt = xmlDoc.xpathNewContext()
for seg in ctxt.xpathEval("//seg"):
print seg.prop("subtype")
print seg.prop("function")
#############
Thanks for any help.
--
Nicolas Mazziotta
The contents of this e-mail, including any attachments, are confidential and
are intended for the sole use of the individual or entity to which it is
addressed. Any distribution, copying or dissemination of this message is
expected to conform to all legal stipulations governing the use of
information.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]