[Zope] XMLDocument Question
Curtis Maloney
curtis@umd.com.au
Wed, 1 Mar 2000 08:54:49 +1100
Green things...
In my experience, objectValues('tagname') is what you're after. It will
return a list of all children with the tag name of 'tagnam'.
so, to get the paragraphs of the a file called sample_xml containing:
<html>
<body>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
</html>
you would use:
sample_xml[0].objectValues('body')[0].objectValues('p')
This is code i have used several times. Of course, if you are working over the
body and p tags seperately, you can use:
<dtml-in "sample_xml[0].objectValues('body')">
<do things here>
<dtml-in "objectValues('p')">
<do paragraph things here>
</dtml-in>
</dtml-in>
Is this the sort of info you were after?
Hope I've helped some...
On Wed, 01 Mar 2000, you wrote:
> Thanks for the reply,
>
> More specifically, I want to output html that does one of two things:
>
> 1 - output the first two paragraphs for a summary in a table of contents
> <html><body>
> <p>Paragraph 1.
> <p>Paragraph 2.
> </body></html>
>
> 2 - output all the paragraphs.
>
> In other words I want a DTML method that I can use from the object containing
> the <p>Paragraph 1.</p> in the XML. So let's say I have a method called
> paraRender sitting in a folder and a DTML document called viewBody that calls
> this method by invoking the paraRender method for each paragraph in the
> document.
>
> I have ha no trouble working with attributes, and even with text content in
> tags, as long as the tagnames are not duplicated within the same parent
> object/tag. In other words, since the <block> element object in the below XML
> contains multiple paragraphs, how do I deal with it?
>
> Thanks,
> Sean
>
> On Mon, 28 Feb 2000, you wrote:
> > Hi there, Sean
> >
> > On Tue, 29 Feb 2000, you wrote:
> > > Quick XMLDocument Question.
> > >
> > > A DTD that I am working with has a structure that looks something like this:
> > >
> > > <body.content>
> > > <block>
> > > <p>Paragraph 1.</p>
> > > <p>Paragraph 2.</p>
> > > <p>Paragraph 3.</p>
> > > <p>Paragraph 4.</p>
> > > </block>
> > > </body.content>
> > >
> >
> > looks simple enough...
> >
> > > I need to be able to use dtml methods to map such paragraphs to html
> > paragraphs > within a dtml document to display the whole document using Zope
> > and XMLDocument > as a kind of server-side style sheet.
> > >
> >
> > erm... could you perhaps explain a little more? I've used XML in a couple of
> > ZOPE projects, and would love to help you... but I am unclear on exactly what
> > you are trying to do...
> >
> > > This should be easy, but I can't find docs to figure it out myself. Anyone
> > got > some quick answers?
> > >
> > > Thanks in advance,
> > > Sean
> > >
> >
> > Have a better one,
> > Curtis.
> >
> > <dtml-var standard_work_disclaimer>
--
Have a better one,
Curtis.
<dtml-var standard_work_disclaimer>