Monday, 24 November 2014

Get result from xml code with python



I have an xml code from nimbuzz chat app to search for chatroom in nimbuzz server using input keyword.



<iq type="set" id="Nimbuzz_SearchRooms" to="conference.nimbuzz.com"><query xmlns="jabber:iqearch"><set xmlns="http://ift.tt/1jsKSY9"><index>0</index><max>10</max></set><x type="get" xmlns="jabberata"><field var="name"><value>**INPUT KEYWORD FOR ROOM NAME**</value></field><field var="include_password_protected"><value>true</value></field></x></query></iq>


The code working and i get the result as xml code:


See the image:


The result code image


I was start with this code but i can't complate because i can't understand how it works:



def handler_search_room(type, source, parameters):
Key_word = raw_input("Please write the Key word: ")
if parameters.split():
iq = xmpp.Iq('set')
iq.setID('Nimbuzz_SearchRooms')
iq.setTo('conference.nimbuzz.com)


I need to send the first code to the nimbuzz server then i need to get the reult with the information of each Chatroom. The result code get this information for each chatroom:




  • name




  • subject.




  • num_users




  • num_max_users




  • is_passowrd_protected




  • is_member_only




  • language




  • location-type




  • location




Please how i can do that with python i will happy if someone help me to make my code.


Download the XML code if you want:


http://ift.tt/11QldRJ


No comments:

Post a Comment