本文整理匯總了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;
}