[Zope] libxml2 help

Steve Lenti slenti at abqpubco.com
Tue Dec 23 10:03:14 EST 2003


On Tue, Dec 23, 2003 at 01:02:01AM -0300, Gabriel Genellina wrote:
> At 22/12/2003 16:08, you wrote:
> 
> >I am trying to parse xml with libxml2.  I have DTML Docs in a Zcatalog
> >that are xml formatted.  I am trying to use a python script to display
> >the xmls using the xpath function of libxml2.  The problem I am having
> >is that in the Results method I have this.
> >
> ><dtml-var expr="parseXML(legal=getobject(data_record_id_))">
> >
> >the problem is that when the content of this variable gets sent
> >to my parseXML python script all the xml tags get replaced with the html
> >encoded versions of the tags ( ie. < and > get replaced with &lt; and
> >&gt; ) I'm not calling the html_quote function so I don't understand why
> >it is replacing the tags.
> 
> It's a bit confusing... A DTMLDocument is a template, how do you catalog 
> it? If it's static, you could use a File object by example. Else, you are 
> cataloging a *rendered* version of the template, but how do you restore it 
> without having the original arguments? ZCatalog just stores a path or id.
> Anyway, getobject() returns the cataloged object, your DTMLDocument, not a 
> string. You surely are converting it to string somehow, maybe by calling it 
> or by using str(). Try using read() or document_src() instead, maybe this 
> is what you are looking for.
> 
> 

Thanks for your reply.  It looks like the document_src() method is
exactly what I was looking for.  I had found another way of doing this
but I don't think it was very clean.  What I did was created a external
python script and used getpath() method for the Zcatalog DTMLDocument.
Then using urllib I grabbed the DTMLDocument directly and read it line
for line into a string then parsed it.  Like I said, not very clean at
all.  Thanks again for your help.

-- 
Steve Lenti
Systems Analyst

You have an unusual understanding of the problems of human relationships.



More information about the Zope mailing list