public static void CreateNode(XMPPClient connection, string strNode, string strParentNode, PubSubConfigForm nodeform) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); string strXML = CreateNodeXML.Replace("#NODE#", strNode); /// Get inner xml /// string strForm = nodeform.BuildAskingForm(nodeform); strXML = strXML.Replace("#x#", strForm); pubsub.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if (IQResponse == null) { return; } if (IQResponse.Type == IQType.error.ToString()) { return; } }
public static string[] GetRootNodes(XMPPClient connection) { List <string> SubNodeList = new List <string>(); string strXML = FetchChildNodesRoot; IQ IQRequest = new IQ(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.Type = IQType.get.ToString(); IQRequest.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000); if (IQResponse == null) { return(null); } if (IQResponse.Type == IQType.error.ToString()) { return(SubNodeList.ToArray()); } var nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/disco#items}item"); foreach (XElement elem in nodes) { XAttribute attrnode = elem.Attribute("node"); SubNodeList.Add(attrnode.Value); } return(SubNodeList.ToArray()); }
public static string[] GetNodeItems(XMPPClient connection, string strNode, out string strNodeJID) { strNodeJID = ""; List <string> returnnodes = new List <string>(); IQ IQRequest = new IQ(); IQRequest.Type = IQType.get.ToString(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = GetNodeItemsXML.Replace("#NODE#", strNode);; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 30000); if (IQResponse.Type == IQType.error.ToString()) { return(returnnodes.ToArray()); } var nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/pubsub}items"); foreach (XElement elem in nodes) { strNodeJID = elem.Attribute("node").Value; } nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/pubsub}item"); foreach (XElement elem in nodes) { returnnodes.Add(elem.Value); } return(returnnodes.ToArray()); }
//public const string DeleteRosterQuery = @"<query xmlns=""jabber:iq:roster""><item jid=""##JID##"" subscription=""remove"" /></query>"; public void DeleteFromRoster(JID jid) { //<iq from='[email protected]/balcony' // id='hm4hs97y' // type='set'> // <query xmlns='jabber:iq:roster'> // <item jid='*****@*****.**' // subscription='remove'/> // </query> // </iq> //string strDeleteQuery = DeleteRosterQuery.Replace("##JID##", jid.BareJID); RosterIQ DeleteRosterIQ = new RosterIQ(); //DeleteRosterIQ.InnerXML = strDeleteQuery; DeleteRosterIQ.Type = IQType.set.ToString(); DeleteRosterIQ.To = null; DeleteRosterIQ.From = XMPPClient.JID; //DeleteRosterIQ.xmlns = "jabber:client"; rosteritem deleteitem = new rosteritem(); deleteitem.JID = jid; deleteitem.Subscription = subscription.remove.ToString(); DeleteRosterIQ.Query.RosterItems = new rosteritem[] { deleteitem }; IQ IQResponse = XMPPClient.SendRecieveIQ(DeleteRosterIQ, 10000); if (IQResponse != null) { } }
/// <summary> /// Purges the items in a node /// </summary> /// <param name="strNode"></param> /// <returns></returns> public static bool UnsubscribeNode(XMPPClient connection, string strNode, string strJID, string strSID, bool bWaitForResponse) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); pubsub.InnerXML = UnsubscribeNodeXML.Replace("#NODE#", strNode).Replace("#JID#", strJID).Replace("#SID#", strSID); if (bWaitForResponse == false) { connection.SendXMPP(pubsub); return(true); } IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if (IQResponse.Type == IQType.error.ToString()) { return(false); } return(true); }
//public const string AddRosterQuery = @"<query xmlns=""jabber:iq:roster""><item jid=""##JID##"" name=""##NAME##""><group>##GROUP##</group></item></query>"; public void AddToRoster(JID jid, string strName, string strGroup) { //<iq from='[email protected]/balcony' // id='ph1xaz53' // type='set'> // <query xmlns='jabber:iq:roster'> // <item jid='*****@*****.**' // name='Nurse'> // <group>Servants</group> // </item> // </query> // </iq> //string strAddQuery = AddRosterQuery.Replace("##JID##", jid.BareJID); //strAddQuery = strAddQuery.Replace("##NAME##", strName); //strAddQuery = strAddQuery.Replace("##GROUP##", strGroup); RosterIQ AddRosterIQ = new RosterIQ(); AddRosterIQ.Type = IQType.set.ToString(); AddRosterIQ.To = null; AddRosterIQ.From = XMPPClient.JID; rosteritem newitem = new rosteritem(); newitem.Name = strName; JID newjid = jid; if (newjid.User.Length <= 0) { newjid.User = newjid.Domain; newjid.Domain = XMPPClient.JID.Domain; } newitem.JID = newjid; newitem.Subscription = subscription.none.ToString(); newitem.Groups = new string[] { strGroup }; AddRosterIQ.Query.RosterItems = new rosteritem[] { newitem }; IQ IQResponse = XMPPClient.SendRecieveIQ(AddRosterIQ, 10000); if (IQResponse != null) { } }
void QueryItemType(item item) { if (item.ItemType == ItemType.NotQueried) { ServiceDiscoveryIQ iqqueryproxy = new ServiceDiscoveryIQ(); iqqueryproxy.From = XMPPClient.JID; iqqueryproxy.To = item.JID; iqqueryproxy.ServiceDiscoveryInfoQuery = new ServiceDiscoveryInfoQuery(); iqqueryproxy.Type = IQType.get.ToString(); IQ iqret = XMPPClient.SendRecieveIQ(iqqueryproxy, 15000, SerializationMethod.XMLSerializeObject); if ((iqret != null) && (iqret is ServiceDiscoveryIQ)) { ServiceDiscoveryIQ response = iqret as ServiceDiscoveryIQ; if ((response.ServiceDiscoveryInfoQuery != null) && (response.ServiceDiscoveryInfoQuery.Identities != null) && (response.ServiceDiscoveryInfoQuery.Identities.Length > 0)) { if ((response.ServiceDiscoveryInfoQuery.Identities[0].Category == "proxy") && (response.ServiceDiscoveryInfoQuery.Identities[0].Type == "bytestreams")) { item.ItemType = ItemType.SOCKS5ByteStream; return; } if (response.ServiceDiscoveryInfoQuery.Identities[0].Category == "pubsub") { item.ItemType = ItemType.PubSub; return; } if (response.ServiceDiscoveryInfoQuery.Identities[0].Category == "directory") { item.ItemType = ItemType.Directory; return; } if (response.ServiceDiscoveryInfoQuery.Identities[0].Category == "conference") { item.ItemType = ItemType.Conference; return; } } } item.ItemType = ItemType.Unknown; } }
public static bool DeleteNode(XMPPClient connection, string strNode) { string strXML = DeleteNodeXML.Replace("#NODE#", strNode); IQ IQRequest = new IQ(); IQRequest.Type = IQType.set.ToString(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000); if (IQResponse.Type == IQType.error.ToString()) { return(false); } return(true); }
/// <summary> /// Purges the items in a node /// </summary> /// <param name="strNode"></param> /// <returns></returns> public static string SubscribeNode(XMPPClient connection, string strNode, string strJID, bool bWaitForResponse) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); pubsub.InnerXML = SubscribeNodeXML.Replace("#NODE#", strNode).Replace("#JID#", strJID); if (bWaitForResponse == false) { connection.SendXMPP(pubsub); return(null); } IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if ((IQResponse == null) || (IQResponse.Type == IQType.error.ToString())) { return(null); } ///<iq type="result" id="9933bb36-7685-460f-8d7f-e9e5ad80f780" from="pubsub.ninethumbs.com" to="[email protected]/9047e898-aed2-4f58-b3e2-a5f671758544"> /// <pubsub xmlns="http://jabber.org/protocol/pubsub"> /// <subscription node="GroceryList" jid="[email protected]/9047e898-aed2-4f58-b3e2-a5f671758544" subid="tU98QlKDYuEhTiKO443Vs2AWi2Y07i4Pf2l1wc8W" subscription="subscribed"> /// <subscribe-options/></subscription> /// </pubsub> /// </iq> /// if (IQResponse is PubSubIQ) { PubSubIQ psiq = IQResponse as PubSubIQ; if ((psiq.PubSub != null) && (psiq.PubSub.Subscription != null)) { return(psiq.PubSub.Subscription.subid); } } return(null); }
/// <summary> /// Retracts an item on the pubsub node. This client must be the owner /// </summary> /// <param name="strNode"></param> /// <param name="strItem"></param> /// <param name="nTimeoutMs"></param> /// <returns></returns> public static bool RetractItem(XMPPClient connection, string strNode, string strItem) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); string strXML = RetractNodeXML.Replace("#NODE#", strNode); strXML = strXML.Replace("#ITEM#", strItem); pubsub.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if (IQResponse.Type == IQType.error.ToString()) { return(false); } return(true); }
/// <summary> /// Checks to see if a given node exists /// </summary> /// <param name="connection"></param> /// <param name="strNode"></param> /// <returns></returns> public static bool NodeExists(XMPPClient connection, string strNode) { string strXML = QueryNodeXML.Replace("#NODE#", strNode); IQ IQRequest = new IQ(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000); if (IQResponse == null) { return(false); } if (IQResponse.Type == IQType.error.ToString()) // && (IQResponse.Error.Code >= 0)) { return(false); } return(true); }
public static IQ RequestItem(XMPPClient connection, string strNode, string strItemName) { IQ pubsub = new IQ(); pubsub.Type = IQType.get.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); string strXML = RequestItemXML.Replace("#NODE#", strNode); strXML = strXML.Replace("#ITEM#", strItemName); pubsub.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(pubsub, 15000); if (IQResponse.Type == IQType.error.ToString()) { return(null); } return(IQResponse); }
/// <summary> /// Purges the items in a node /// </summary> /// <param name="strNode"></param> /// <returns></returns> public static bool UnsubscribeNode(XMPPClient connection, string strNode, string strJID, string strSID, bool bWaitForResponse) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); pubsub.InnerXML = UnsubscribeNodeXML.Replace("#NODE#", strNode).Replace("#JID#", strJID).Replace("#SID#", strSID); if (bWaitForResponse == false) { connection.SendXMPP(pubsub); return true; } IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if (IQResponse.Type == IQType.error.ToString()) { return false; } return true; }
/// <summary> /// Purges the items in a node /// </summary> /// <param name="strNode"></param> /// <returns></returns> public static string SubscribeNode(XMPPClient connection, string strNode, string strJID, bool bWaitForResponse) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); pubsub.InnerXML = SubscribeNodeXML.Replace("#NODE#", strNode).Replace("#JID#", strJID); if (bWaitForResponse == false) { connection.SendXMPP(pubsub); return null; } IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if ( (IQResponse == null) || (IQResponse.Type == IQType.error.ToString()) ) { return null; } ///<iq type="result" id="9933bb36-7685-460f-8d7f-e9e5ad80f780" from="pubsub.ninethumbs.com" to="[email protected]/9047e898-aed2-4f58-b3e2-a5f671758544"> /// <pubsub xmlns="http://jabber.org/protocol/pubsub"> /// <subscription node="GroceryList" jid="[email protected]/9047e898-aed2-4f58-b3e2-a5f671758544" subid="tU98QlKDYuEhTiKO443Vs2AWi2Y07i4Pf2l1wc8W" subscription="subscribed"> /// <subscribe-options/></subscription> /// </pubsub> /// </iq> /// if (IQResponse is PubSubIQ) { PubSubIQ psiq = IQResponse as PubSubIQ; if ( (psiq.PubSub != null) && (psiq.PubSub.Subscription != null) ) return psiq.PubSub.Subscription.subid; } return null; }
/// <summary> /// Retracts an item on the pubsub node. This client must be the owner /// </summary> /// <param name="strNode"></param> /// <param name="strItem"></param> /// <param name="nTimeoutMs"></param> /// <returns></returns> public static bool RetractItem(XMPPClient connection, string strNode, string strItem) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); string strXML = RetractNodeXML.Replace("#NODE#", strNode); strXML = strXML.Replace("#ITEM#", strItem); pubsub.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if (IQResponse.Type == IQType.error.ToString()) { return false; } return true; }
public static IQ RequestItem(XMPPClient connection, string strNode, string strItemName) { IQ pubsub = new IQ(); pubsub.Type = IQType.get.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); string strXML = RequestItemXML.Replace("#NODE#", strNode); strXML = strXML.Replace("#ITEM#", strItemName); pubsub.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(pubsub, 15000); if (IQResponse.Type == IQType.error.ToString()) { return null; } return IQResponse; }
/// <summary> /// Checks to see if a given node exists /// </summary> /// <param name="connection"></param> /// <param name="strNode"></param> /// <returns></returns> public static bool NodeExists(XMPPClient connection, string strNode) { string strXML = QueryNodeXML.Replace("#NODE#", strNode); IQ IQRequest = new IQ(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000); if (IQResponse == null) return false; if (IQResponse.Type == IQType.error.ToString()) // && (IQResponse.Error.Code >= 0)) { return false; } return true; }
public static string[] GetSubNodes(XMPPClient connection, string strNode) { List<string> SubNodeList = new List<string>(); string strXML = FetchChildNodes.Replace("#NODE#", strNode); ServiceDiscoveryIQ IQRequest = new ServiceDiscoveryIQ(); IQRequest.ServiceDiscoveryItemQuery = new ServiceDiscoveryItemQuery(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.Type = IQType.get.ToString(); IQRequest.ServiceDiscoveryItemQuery.Node = strNode; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000, SerializationMethod.XMLSerializeObject); if (IQResponse == null) return null; if (IQResponse.Type == IQType.error.ToString()) { return SubNodeList.ToArray(); } if (IQResponse is ServiceDiscoveryIQ) { ServiceDiscoveryIQ sdiq = IQResponse as ServiceDiscoveryIQ; if ((sdiq.ServiceDiscoveryItemQuery != null) && (sdiq.ServiceDiscoveryItemQuery.Items != null) ) { foreach (item it in sdiq.ServiceDiscoveryItemQuery.Items) { SubNodeList.Add(it.Node); } } } //var nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/disco#items}item"); //foreach (XElement elem in nodes) //{ // XAttribute attrnode = elem.Attribute("node"); // if (attrnode != null) // SubNodeList.Add(attrnode.Value); //} return SubNodeList.ToArray(); }
public static string[] GetNodeItemStrings(XMPPClient connection, string strNode, out string strNodeJID) { strNodeJID = ""; List<string> returnnodes = new List<string>(); PubSubIQ IQRequest = new PubSubIQ(); IQRequest.Type = IQType.get.ToString(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.PubSub = new PubSub(); IQRequest.PubSub.Items = new PubSubItems(); IQRequest.PubSub.Items.Node = strNode; //IQRequest.InnerXML = GetNodeItemsXML.Replace("#NODE#", strNode);; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 30000, SerializationMethod.XMLSerializeObject); if (IQResponse.Type == IQType.error.ToString()) { return returnnodes.ToArray(); } if (IQResponse is PubSubIQ) { PubSubIQ psiq = IQResponse as PubSubIQ; if ((psiq.PubSub != null) && (psiq.PubSub.Items != null) ) { strNodeJID = psiq.PubSub.Items.Node; if (psiq.PubSub.Items.Items != null) { foreach (PubSubItem item in psiq.PubSub.Items.Items) { returnnodes.Add(item.InnerItemXML.Value); } } } } //var nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/pubsub}items"); //foreach (XElement elem in nodes) //{ // strNodeJID = elem.Attribute("node").Value; //} //nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/pubsub}item"); //foreach (XElement elem in nodes) //{ // returnnodes.Add(elem.Value); //} return returnnodes.ToArray(); }
public static PubSubItem[] GetNodeItems(XMPPClient connection, string strNode, out string strNodeJID) { strNodeJID = ""; List<PubSubItem> returnnodes = new List<PubSubItem>(); PubSubIQ IQRequest = new PubSubIQ(); IQRequest.Type = IQType.get.ToString(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.PubSub = new PubSub(); IQRequest.PubSub.Items = new PubSubItems(); IQRequest.PubSub.Items.Node = strNode; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 30000, SerializationMethod.XMLSerializeObject); if (IQResponse.Type == IQType.error.ToString()) { return returnnodes.ToArray(); } if (IQResponse is PubSubIQ) { PubSubIQ psiq = IQResponse as PubSubIQ; if ((psiq.PubSub != null) && (psiq.PubSub.Items != null)) { strNodeJID = psiq.PubSub.Items.Node; if (psiq.PubSub.Items.Items != null) { foreach (PubSubItem item in psiq.PubSub.Items.Items) { returnnodes.Add(item); } } } } return returnnodes.ToArray(); }
public static string[] GetSubNodes(XMPPClient connection, string strNode) { List<string> SubNodeList = new List<string>(); string strXML = FetchChildNodes.Replace("#NODE#", strNode); IQ IQRequest = new IQ(); IQRequest.From = connection.JID; IQRequest.Type = IQType.get.ToString(); IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000); if (IQResponse == null) return null; if (IQResponse.Type == IQType.error.ToString()) { return SubNodeList.ToArray(); } var nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/disco#items}item"); foreach (XElement elem in nodes) { XAttribute attrnode = elem.Attribute("node"); if (attrnode != null) SubNodeList.Add(attrnode.Value); } return SubNodeList.ToArray(); }
public static string[] GetNodeItems(XMPPClient connection, string strNode, out string strNodeJID) { strNodeJID = ""; List<string> returnnodes = new List<string>(); IQ IQRequest = new IQ(); IQRequest.Type = IQType.get.ToString(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = GetNodeItemsXML.Replace("#NODE#", strNode);; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 30000); if (IQResponse.Type == IQType.error.ToString()) { return returnnodes.ToArray(); } var nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/pubsub}items"); foreach (XElement elem in nodes) { strNodeJID = elem.Attribute("node").Value; } nodes = IQResponse.InitalXMLElement.Descendants("{http://jabber.org/protocol/pubsub}item"); foreach (XElement elem in nodes) { returnnodes.Add(elem.Value); } return returnnodes.ToArray(); }
public static void CreateNode(XMPPClient connection, string strNode, string strParentNode, PubSubConfigForm nodeform) { IQ pubsub = new IQ(); pubsub.Type = IQType.set.ToString(); pubsub.From = connection.JID; pubsub.To = new JID(string.Format("pubsub.{0}", connection.Domain)); string strXML = CreateNodeXML.Replace("#NODE#", strNode); /// Get inner xml /// string strForm = nodeform.BuildAskingForm(nodeform); strXML = strXML.Replace("#x#", strForm); pubsub.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(pubsub, 10000); if (IQResponse == null) return; if (IQResponse.Type == IQType.error.ToString()) { return; } }
public static bool DeleteNode(XMPPClient connection, string strNode) { string strXML = DeleteNodeXML.Replace("#NODE#", strNode); IQ IQRequest = new IQ(); IQRequest.Type = IQType.set.ToString(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.InnerXML = strXML; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000); if (IQResponse.Type == IQType.error.ToString()) { return false; } return true; }
public static item[] GetSubNodeItems(XMPPClient connection, string strNode) { List<item> SubNodeList = new List<item>(); ServiceDiscoveryIQ IQRequest = new ServiceDiscoveryIQ(); IQRequest.ServiceDiscoveryItemQuery = new ServiceDiscoveryItemQuery(); IQRequest.From = connection.JID; IQRequest.To = string.Format("pubsub.{0}", connection.Domain); IQRequest.Type = IQType.get.ToString(); IQRequest.ServiceDiscoveryItemQuery.Node = strNode; IQ IQResponse = connection.SendRecieveIQ(IQRequest, 10000, SerializationMethod.XMLSerializeObject); if (IQResponse == null) return null; if (IQResponse.Type == IQType.error.ToString()) { return SubNodeList.ToArray(); } if (IQResponse is ServiceDiscoveryIQ) { ServiceDiscoveryIQ sdiq = IQResponse as ServiceDiscoveryIQ; if ((sdiq.ServiceDiscoveryItemQuery != null) && (sdiq.ServiceDiscoveryItemQuery.Items != null)) { foreach (item it in sdiq.ServiceDiscoveryItemQuery.Items) { SubNodeList.Add(it); } } } return SubNodeList.ToArray(); }