xmllib, how it works?

Francesco francesco.contini at infinito.it
Mon Dec 18 14:11:17 EST 2000


Hi!

Some one can explain me how can i use xmllib.XMLParser class ?

i've tried to write code from the xmllib manual page, bu there are some thing that i cannot understand...

for example
i've a document like this:
<? XML blah blah blah ?>
<LISTIMAGES>
    <IMAGE WIDTH=80 HEIGHT=40 URL="http://myserver/test.jpg">
        <ALTERNATE>Test Default Image</ALTERNATE>
        <REFERRERTO>http://myserver/mypage.html</REFERRERTO>
        <DESCRIPTION type="text" length=620>This is the description of the link .... </DESCRIPTION>
    </IMAGE>
    <IMAGE ....
    </IMAGE>

    and so on...
</LISTIMAGES>


instance the class:
X=xmllib.XMLParser()

setted the elements
X.elements={'IMAGE':(startimage,endimage), 'ALTERNATE':(startalternate,endalternate), 'DESCRIPTION':(startdesc,enddesc)}

assuming that the variable FILE contains the XML document
i run:

X.feed(FILE)

the problem is that i cannot retrive the text between <ALTERNATE></ALTERNATE>,<DESCRIPTION></DESCRIPTION> and <REFERRER></REFERRER>


i've tried to set X.attributes but i cannot understand what kind of object or functions i must put into, 
and for now the format of the attribute dict is for me impossible to understand.

There's someone that know how this class works?

please reply to my address too.

Thanks a lot!




More information about the Python-list mailing list