Ignore:
Timestamp:
Jun 25, 2008, 1:06:55 PM (13 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@54
Message:

PubSubService?.items should return a list of Elements representing items.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/generic.py

    r20 r24  
    1313from twisted.words.protocols.jabber import error
    1414from twisted.words.protocols.jabber.xmlstream import toResponse
     15from twisted.words.xish import domish
    1516
    1617from wokkel import disco
     
    2324NS_VERSION = 'jabber:iq:version'
    2425VERSION = IQ_GET + '/query[@xmlns="' + NS_VERSION + '"]'
     26
     27def parseXml(string):
     28    """
     29    Parse serialized XML into a DOM structure.
     30
     31    @param string: The serialized XML to be parsed, UTF-8 encoded.
     32    @type string: C{str}.
     33    @return: The DOM structure, or C{None} on empty or incomplete input.
     34    @rtype: L{domish.Element}
     35    """
     36    roots = []
     37    results = []
     38    elementStream = domish.elementStream()
     39    elementStream.DocumentStartEvent = roots.append
     40    elementStream.ElementEvent = lambda elem: roots[0].addChild(elem)
     41    elementStream.DocumentEndEvent = lambda: results.append(roots[0])
     42    elementStream.parse(string)
     43    return results and results[0] or None
     44
     45
    2546
    2647class FallbackHandler(XMPPHandler):
Note: See TracChangeset for help on using the changeset viewer.