Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
Huntsman #1
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
Subject: How to read jid value from IQ
hello AGS and alex sir,

please help me to read room jid value from IQ. .i just search conference rooms with the keyword "india" and the return xml is


  1. <iq from="conference.nimbuzz.com" type="result" to="user@nimbuzz.com/AgsXMPP" id="27">
  2.     <query xmlns="jabber:iq:search">
  3.         <x xmlns="jabber:x:data">
  4.             <reported>
  5.                 <field type="text-single" label="Name" var="name">
  6.                 </field>
  7.                 <field type="text-single" label="Subject" var="subject">
  8.                 </field>
  9.                 <field type="text-single" label="Language code" var="language">
  10.                 </field>
  11.                 <field type="text-single" label="Number of users" var="num_users">
  12.                 </field>
  13.                 <field type="text-single" label="Max number of users allowed" var="num_max_users">
  14.                 </field>
  15.                 <field type="boolean" label="Is a password protected room" var="is_password_protected">
  16.                 </field>
  17.                 <field type="boolean" label="Is a member only room" var="is_member_only">
  18.                 </field>
  19.                 <field type="list-single" label="Location type" var="location-type">
  20.                 </field>
  21.                 <field type="text-single" label="Location code" var="location">
  22.                 </field>
  23.                 <field type="jid-single" label="JID" var="jid">
  24.                 </field>
  25.             </reported>
  26.             <item>
  27.                 <field type="text-single" var="name">
  28.                     <value>indian</value>
  29.                 </field>
  30.                 <field type="text-single" var="subject">
  31.                     <value>Send SPIN to spin the wheel!</value>
  32.                 </field>
  33.                 <field type="text-single" var="num_users">
  34.                     <value>6</value>
  35.                 </field>
  36.                 <field type="text-single" var="num_max_users">
  37.                     <value>25</value>
  38.                 </field>
  39.                 <field type="boolean" var="is_password_protected">
  40.                     <value>false</value>
  41.                 </field>
  42.                 <field type="boolean" var="is_member_only">
  43.                     <value>false</value>
  44.                 </field>
  45.                 <field type="text-single" var="language">
  46.                     <value>en</value>
  47.                 </field>
  48.                 <field type="list-single" var="location-type">
  49.                     <value>worldwide</value>
  50.                 </field>
  51.                 <field type="text-single" var="location">
  52.                     <value>
  53.                     </value>
  54.                 </field>
  55.                 <field type="jid-single" var="jid">
  56.                     <value>indian@conference.nimbuzz.com</value>
  57.                 </field>
  58.             </item>
  59.             <item>
  60.                 <field type="text-single" var="name">
  61.                     <value>indian$</value>
  62.                 </field>
  63.                 <field type="text-single" var="subject">
  64.                     <value>xBot!</value>
  65.                 </field>
  66.                 <field type="text-single" var="num_users">
  67.                     <value>1</value>
  68.                 </field>
  69.                 <field type="text-single" var="num_max_users">
  70.                     <value>25</value>
  71.                 </field>
  72.                 <field type="boolean" var="is_password_protected">
  73.                     <value>false</value>
  74.                 </field>
  75.                 <field type="boolean" var="is_member_only">
  76.                     <value>false</value>
  77.                 </field>
  78.                 <field type="text-single" var="language">
  79.                     <value>
  80.                     </value>
  81.                 </field>
  82.                 <field type="list-single" var="location-type">
  83.                     <value>
  84.                     </value>
  85.                 </field>
  86.                 <field type="text-single" var="location">
  87.                     <value>
  88.                     </value>
  89.                 </field>
  90.                 <field type="jid-single" var="jid">
  91.                     <value>indian$@conference.nimbuzz.com</value>
  92.                 </field>
  93.             </item>
  94.             <item>
  95.                 <field type="text-single" var="name">
  96.                     <value>indian?</value>
  97.                 </field>
  98.                 <field type="text-single" var="subject">
  99.                     <value>KPV SERVER V 12.4.4</value>
  100.                 </field>
  101.                 <field type="text-single" var="num_users">
  102.                     <value>1</value>
  103.                 </field>
  104.                 <field type="text-single" var="num_max_users">
  105.                     <value>25</value>
  106.                 </field>
  107.                 <field type="boolean" var="is_password_protected">
  108.                     <value>false</value>
  109.                 </field>
  110.                 <field type="boolean" var="is_member_only">
  111.                     <value>false</value>
  112.                 </field>
  113.                 <field type="text-single" var="language">
  114.                     <value>
  115.                     </value>
  116.                 </field>
  117.                 <field type="list-single" var="location-type">
  118.                     <value>worldwide</value>
  119.                 </field>
  120.                 <field type="text-single" var="location">
  121.                     <value>
  122.                     </value>
  123.                 </field>
  124.                 <field type="jid-single" var="jid">
  125.                     <value>indian?@conference.nimbuzz.com</value>
  126.                 </field>
  127.             </item>
  128.             <item>
  129.                 <field type="text-single" var="name">
  130.                     <value>indian-</value>
  131.                 </field>
  132.                 <field type="text-single" var="subject">
  133.                     <value>
  134.                     </value>
  135.                 </field>
  136.                 <field type="text-single" var="num_users">
  137.                     <value>1</value>
  138.                 </field>
  139.                 <field type="text-single" var="num_max_users">
  140.                     <value>25</value>
  141.                 </field>
  142.                 <field type="boolean" var="is_password_protected">
  143.                     <value>false</value>
  144.                 </field>
  145.                 <field type="boolean" var="is_member_only">
  146.                     <value>false</value>
  147.                 </field>
  148.                 <field type="text-single" var="language">
  149.                     <value>en</value>
  150.                 </field>
  151.                 <field type="list-single" var="location-type">
  152.                     <value>worldwide</value>
  153.                 </field>
  154.                 <field type="text-single" var="location">
  155.                     <value>
  156.                     </value>
  157.                 </field>
  158.                 <field type="jid-single" var="jid">
  159.                     <value>indian-@conference.nimbuzz.com</value>
  160.                 </field>
  161.             </item>
  162.         </x>
  163.         <set xmlns="http://jabber.org/protocol/rsm">
  164.             <count>166</count>
  165.             <first index="0">india@conference.nimbuzz.com</first>
  166.             <last>indian_@conference.nimbuzz.com</last>
  167.         </set>
  168.     </query>
  169. </iq>
This post was edited 4 times, last on 2016-04-21, 10:13 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If you format your XML properly which I have done now, you can see that the returned xdata object contains multiple items.
Every item has multiple fields. And there is a fields with var=jid. So loop over the items, look for this fields and get the value.
This should be pretty easy with the xdata classes in agsXMPP.
Avatar
Huntsman #3
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
thank you for your help alex sir. i couldn't post full xml here because of text legnth limitation. please download the attachment and check the full xml.
The author has attached one file to this post:
nimbuzz room search xmls.txt 79.2 kBytes
You have no permission to open this file.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this log is exactly the same, just containing much more items/results.

Alex
Avatar
Huntsman #5
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
yes sir, but i want to know that how to read all room jid value from it. im too much beginner in agsxmpp. i want to learn it. agsxmpp is the best xmpp library.
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
here is a c# code sample which outputs all the Jids:

  1. var xdata = iq.Query.SelectSingleElement<Data>();
  2. xdata
  3.     .GetItems()
  4.     .ToList()
  5.     .ForEach(i =>
  6.     {
  7.         var jidField = i.GetField("jid");
  8.         if (jidField != null)
  9.             System.Diagnostics.Debug.WriteLine(jidField.GetValue());
  10.     });
Avatar
Huntsman #7
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
wooooooow... works like a charm alex sir.

thank you very much again for your effort.

you are very kind :)
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS