當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlDocument.SelectNodesNS方法代碼示例

本文整理匯總了C#中Windows.Data.Xml.Dom.XmlDocument.SelectNodesNS方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.SelectNodesNS方法的具體用法?C# XmlDocument.SelectNodesNS怎麽用?C# XmlDocument.SelectNodesNS使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Data.Xml.Dom.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.SelectNodesNS方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: probeTask

        internal async Task<IList<Camera>> probeTask()
        { 
            var cameras = new List<Camera>();
            var cameraAddressMap = new Dictionary<string, Camera>();

            listener.MessageReceived +=  (DatagramSocket sender, DatagramSocketMessageReceivedEventArgs args) =>
            {
                try
                {
                    var reader = args.GetDataReader();
                    var bytesRemaining = reader.UnconsumedBufferLength;
                    var receivedString = reader.ReadString(bytesRemaining);

                    var soapEnvelope = new XmlDocument();
                    soapEnvelope.LoadXml(receivedString);

                    //var probeMatches = soapEnvelope.GetElementsByTagName("wsdd:ProbeMatch");
                    var probeMatches = soapEnvelope.SelectNodesNS("//wsdd:ProbeMatch", "xmlns:wsdd='http://schemas.xmlsoap.org/ws/2005/04/discovery'");
                    foreach (var probeMatch in probeMatches)
                    {
                        Debug.WriteLine(probeMatch.GetXml());
                        var endpointAddressNode = probeMatch.SelectSingleNodeNS("wsa:EndpointReference/wsa:Address", "xmlns:wsdd='http://schemas.xmlsoap.org/ws/2005/04/discovery' xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'");

                        var xAddressNode = probeMatch.SelectSingleNodeNS("wsdd:XAddrs", "xmlns:wsdd='http://schemas.xmlsoap.org/ws/2005/04/discovery' xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'");

                        var cameraAddress = endpointAddressNode.InnerText;
                        var cameraUri = xAddressNode.InnerText;

                        if (!cameraAddressMap.ContainsKey(cameraAddress))
                        {
                            var uri = new Uri(cameraUri);
                            var cameraInstance = new Camera(cameraAddress, uri);
                            cameras.Add(cameraInstance);
                            cameraAddressMap.Add(cameraAddress, cameraInstance);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message + "\n" + e.StackTrace);
                }
            };

            await listener.BindEndpointAsync(null, string.Empty);
            var ssdp = new Windows.Networking.HostName("239.255.255.250");
            listener.JoinMulticastGroup(ssdp);


            using (var stream = await listener.GetOutputStreamAsync(ssdp, "3702"))
            {
                using (var writer = new DataWriter(stream))
                {
                    string req = GetRequestString();

                    writer.WriteString(req);
                    await writer.StoreAsync();

                    await Task.Delay(5000);
                }
            }

            return cameras;
        }
開發者ID:ooeygui,項目名稱:UWPOnvif,代碼行數:63,代碼來源:Discover.cs


注:本文中的Windows.Data.Xml.Dom.XmlDocument.SelectNodesNS方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。