[Twisted-Python] Help using XmlStreamFactory & XmlStream : XPathQuery error?
mailing_lists at evotex.ch
Tue Feb 19 06:29:38 EST 2008
Gabriel Rossetti wrote:
> I am trying to write a Server and Client that use an XML protocol. I
> saw that there is a XmlStream class and tried to use it, but was
> unable to. I saw one small example for a client
> (http://ralphm.net/blog/2005/10), but it raises some questions.
> First of all, it seams to work compleatly differently that the other
> server/client examples.
> I don't understand why there is a need to add observers, and what they
> are used for. I can't get any of these to work (on either side, client
> or server):
> def connectionMade(self):
> print 'Connected!'
> def dataReceived(self, data):
> print data
> def onDocumentStart(self, rootElement):
> print "Message start : ", rootElement
> def onElement(self, element):
> print "current element : ", element
> def onDocumentEnd(self, rootElement):
> print "Message end : ", rootElement
> I'm kind of lost :-(
> I'm new to Twisted and I though that I understood how it works (read
> howtos, turorials, etc, but this one doesn't seam like the others. Can
> someone please point me to an example, I searched google but no luck.
> All I need is a simple client-server xml echo example or a better
> understanding of how it works and how it differs from the other echo
> examples. Thank you,
> Thank you
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
Ok, I've got some code sort of working, if I use the following
XPathQuery string : "/*" on the following XML string :
<?xml version="1.0" encoding="utf-8"?>
the addObserver works ( xs.addObserver("/*", self.onTest) )
but if I try the following :
I get the following :
104, in onElement
line 232, in dispatch
line 238, in matches
exceptions.AttributeError: 'NoneType' object has no attribute 'matches'
Does anyone understand why?
More information about the Twisted-Python