<s> import pyjd <EOL> from pyjamas . ui . Button import Button <EOL> from pyjamas . ui . RootPanel import RootPanel <EOL> from pyjamas . ui . HTML import HTML <EOL> from pyjamas . ui . DockPanel import DockPanel <EOL> from pyjamas . ui import HasAlignment <EOL> from pyjamas . ui . Hyperlink import Hyperlink <EOL> from pyjamas . ui . VerticalPanel import VerticalPanel <EOL> from pyjamas . ui . ScrollPanel import ScrollPanel <EOL> from pyjamas import Window <EOL> from pyjamas . HTTPRequest import HTTPRequest <EOL> from pyjamas . XMLDoc import create_xml_doc <EOL> class XMLloader : <EOL> def __init__ ( self , panel ) : <EOL> self . panel = panel <EOL> def onCompletion ( self , doc ) : <EOL> self . panel . doStuff ( create_xml_doc ( doc ) ) <EOL> def onError ( self , text , code ) : <EOL> self . panel . onError ( text , code ) <EOL> def onTimeout ( self , text ) : <EOL> self . panel . onTimeout ( text ) <EOL> class XMLload : <EOL> def onModuleLoad ( self ) : <EOL> HTTPRequest ( ) . asyncGet ( "<STR_LIT>" , XMLloader ( self ) ) <EOL> def onError ( self , text , code ) : <EOL> pass <EOL> def onTimeout ( self , text ) : <EOL> pass <EOL> def doStuff ( self , xmldoc ) : <EOL> contacts = xmldoc . getElementsByTagName ( "<STR_LIT>" ) <EOL> len = contacts . length ; <EOL> for i in range ( len ) : <EOL> contactsDom = contacts . item ( i ) <EOL> firstNames = contactsDom . getElementsByTagName ( "<STR_LIT>" ) <EOL> firstNameNode = firstNames . item ( <NUM_LIT:0> ) <EOL> firstName = firstNameNode . firstChild . nodeValue <EOL> RootPanel ( ) . add ( HTML ( "<STR_LIT>" % str ( firstName ) ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pyjd . setup ( "<STR_LIT>" ) <EOL> app = XMLload ( ) <EOL> app . onModuleLoad ( ) <EOL> pyjd . run ( ) </s>
