public static void Main() { XmlNodeReader reader = null; try { //Create and load the XML document. XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' ISBN='1-861003-78'> " + "<title>Pride And Prejudice</title>" + "<price>19.95</price>" + "</book>"); //Load the XmlNodeReader reader = new XmlNodeReader(doc); //Read the attributes on the book element. reader.MoveToContent(); while (reader.MoveToNextAttribute()) { Console.WriteLine("{0} = {1}", reader.Name, reader.Value); } //Move the reader to the title element. reader.Read(); //Read the title and price elements. Console.WriteLine(reader.ReadElementString()); Console.WriteLine(reader.ReadElementString()); } finally { if (reader != null) { reader.Close(); } } }
internal static void ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { XmlElement node = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(), "SslTransportSecurity", "http://schemas.microsoft.com/ws/2006/05/framing/policy", true); if (node != null) { SslStreamSecurityBindingElement item = new SslStreamSecurityBindingElement(); XmlReader reader = new XmlNodeReader(node); reader.ReadStartElement(); item.RequireClientCertificate = reader.IsStartElement("RequireClientCertificate", "http://schemas.microsoft.com/ws/2006/05/framing/policy"); if (item.RequireClientCertificate) { reader.ReadElementString(); } policyContext.BindingElements.Add(item); } }
internal static void ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { XmlElement assertion = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(), TransportPolicyConstants.SslTransportSecurityName, TransportPolicyConstants.DotNetFramingNamespace, true); if (assertion != null) { SslStreamSecurityBindingElement sslBindingElement = new SslStreamSecurityBindingElement(); XmlReader reader = new XmlNodeReader(assertion); reader.ReadStartElement(); sslBindingElement.RequireClientCertificate = reader.IsStartElement( TransportPolicyConstants.RequireClientCertificateName, TransportPolicyConstants.DotNetFramingNamespace); if (sslBindingElement.RequireClientCertificate) { reader.ReadElementString(); } policyContext.BindingElements.Add(sslBindingElement); } }