How to make xml in python does not automatically delete the whitespace in front and behind the string -


how can make xml in python not automatically delete whitespace in front , behind string, because string (string nick) must executed using whitespace in front , behind, need storm-bot jabber (https://code.google.com/p/storm-bot/downloads/list)

for example:

groupchat = 'jabberow@conference.jabber.ru'   nick = '      sherlock     ' (example nick using whitespace @ front & behind)    def order_visitor(groupchat, nick, reason):      iq = xmpp.iq('set')      iq.setto(groupchat)      iq.setid('ulti_visitor')      query = xmpp.node('query')      query.setnamespace('http://jabber.org/protocol/muc#admin')      query.addchild('item', {'nick':nick, 'role':'visitor'})      iq.addchild(node=query)      jcon.send(iq)   

even have tried way:

room = 'jabberow@conference.jabber.ru'   nick = '      sherlock       ' (example nick using whitespace @ front & behind)    setvisitor = xmpp.simplexml.xml2node(unicode("<iq to='"+str(room)+"' type='set' id='itemmuc'><query xmlns='http://jabber.org/protocol/muc#admin'><item role='visitor' nick='"+str(nick)+"'/></query></iq>").encode('utf8'))    jcon.send(setvisitor)   

but result space in front , behind string (string nick) still deleted automatically , alwasy executed "sherlock" , not " sherlock " try remove strip() !!!

can me ?

there no way achieve because if put spaces there not preserved when xml file parsed. xml standard says whitespace in attribute values ”normalized”, i.e. stripped @ front , end , amount of whitespace within stripped string replaced 1 space.

see relevant section in standard: http://www.w3.org/tr/2006/rec-xml11-20060816/#avnormalize


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -