[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [xml] Crashes trying XPath stuff with Python bindings



On 09.06.06 18:55:29, Gary Coady wrote:
> Andreas Pakulat wrote:
> > I'm not sure I'm doing the right thing here, thus I'm not (yet) filing a
> > bugreport. I want to use the python bindings for libxml2 and thus
> > installed libxml2 (2.6.26) and libxslt (1.1.17). Now doing my first
> > steps results in crashes of the python interpreter:
> > 
> >>>> import libxml2
> >>>> doc=libxml2.parseFile('/home/andreas/temp/file1.xml')
> >>>> xpath=libxml2.xpathContext(doc)
> >>>> result=xpath.xpathEvalExpression('//body')
> 
> I'll have to let somebody else comment on whether that *should* work
> (there's no dictionary, so I guess the code should create one?), and I'm
> not sure if that method is supposed to be used by external users.
> 
> But you should be able to get past the problem with
> 
> import libxml2
> doc = libxml2.parseFile('/home/andreas/temp/file1.xml')
> xpath = doc.xpathNewContext()
> result = xpath.xpathEvalExpression('//body')

aah, so the document has a proper function... 

The problem is that there's not real documentation on the python
bindings and the C-API is quite different for these things as it uses
only functions. For example the tutorial code for the above is

xmlXPathContextPtr context;
xmlXPathObjectPtr result;

context = xmlXPathNewContext(doc);
result = xmlXPathEvalExpression(xpath, context)

so I looked for xpathcontext or something similar in libxml2 first and
not on the document first...

Maybe I should let python create some html docs from the docstrings...

Andreas

-- 
Learn to pause -- or nothing worthwhile can catch up to you.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]