diff -r ffa851df0825 -r 2fb8b9db1c86 symbian-qemu-0.9.1-12/python-2.6.1/Doc/includes/minidom-example.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/symbian-qemu-0.9.1-12/python-2.6.1/Doc/includes/minidom-example.py Fri Jul 31 15:01:17 2009 +0100 @@ -0,0 +1,64 @@ +import xml.dom.minidom + +document = """\ + +Demo slideshow +Slide title +This is a demo +Of a program for processing slides + + +Another demo slide +It is important +To have more than +one slide + + +""" + +dom = xml.dom.minidom.parseString(document) + +def getText(nodelist): + rc = "" + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + rc = rc + node.data + return rc + +def handleSlideshow(slideshow): + print "" + handleSlideshowTitle(slideshow.getElementsByTagName("title")[0]) + slides = slideshow.getElementsByTagName("slide") + handleToc(slides) + handleSlides(slides) + print "" + +def handleSlides(slides): + for slide in slides: + handleSlide(slide) + +def handleSlide(slide): + handleSlideTitle(slide.getElementsByTagName("title")[0]) + handlePoints(slide.getElementsByTagName("point")) + +def handleSlideshowTitle(title): + print "%s" % getText(title.childNodes) + +def handleSlideTitle(title): + print "

%s

" % getText(title.childNodes) + +def handlePoints(points): + print "" + +def handlePoint(point): + print "
  • %s
  • " % getText(point.childNodes) + +def handleToc(slides): + for slide in slides: + title = slide.getElementsByTagName("title")[0] + print "

    %s

    " % getText(title.childNodes) + +handleSlideshow(dom)