本文整理汇总了C#中System.Xml.XmlValidatingReader.XmlResolver属性的典型用法代码示例。如果您正苦于以下问题:C# XmlValidatingReader.XmlResolver属性的具体用法?C# XmlValidatingReader.XmlResolver怎么用?C# XmlValidatingReader.XmlResolver使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了XmlValidatingReader.XmlResolver属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlTextReader
// Create the reader.
XmlTextReader txtreader = new XmlTextReader("book5.xml");
XmlValidatingReader reader = new XmlValidatingReader(txtreader);
txtreader.WhitespaceHandling = WhitespaceHandling.None;
// Set the credentials necessary to access the DTD file stored on the network.
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
reader.XmlResolver = resolver;
// Display each of the element nodes.
while (reader.Read()){
switch (reader.NodeType){
case XmlNodeType.Element:
Console.Write("<{0}>", reader.Name);
break;
case XmlNodeType.Text:
Console.Write(reader.Value);
break;
case XmlNodeType.DocumentType:
Console.Write("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value);
break;
case XmlNodeType.EntityReference:
Console.Write(reader.Name);
break;
case XmlNodeType.EndElement:
Console.Write("</{0}>", reader.Name);
break;
}
}