On Thursday 16 December 2004 14:46, [EMAIL PROTECTED] wrote:
> >     # confDocument is a libxml2 document, from parseFile() etc
> >     xp = confDocument.xpathNewContext()
> >     xp.xpathRegisterNs("xhtml", "http://www.w3.org/1999/xhtml";)
> >     dirElement = xp.xpathEval( "/xhtml:html" )
>
> Stupid question, but can the namespace somehow be changed to null to
> make queries simpler?

(I am no libxml2, XML, or Python expert)

There's a danger to that; the namespace is there for a reason. For example, if 
you put all elements in the document into one namespace, that could mean that 
you get elements which not is XHTML, but something else, totally different. 
In case you want to ignore namespaces, you must be 100% sure what the files 
to be processed contains, and that all namespaces that are thrown together 
can be treated equally.

Regarding removing the namespace; you could probably process the DOM tree and 
remove all namespaces, before doing any XPath lookups. Perhaps libxml2 has 
utility functions for things like this(something like recursively set 
namespace for an element). Standard namespace-aware DOM probably has it..

Feel free to post your findings afterwards, although I wouldn't do it in the 
first place :)


Cheers,

                Frans

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to