本文整理汇总了C#中System.Xml.XmlNameTable类的典型用法代码示例。如果您正苦于以下问题:C# XmlNameTable类的具体用法?C# XmlNameTable怎么用?C# XmlNameTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlNameTable类属于System.Xml命名空间,在下文中一共展示了XmlNameTable类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NameTable
// Add the element names to the NameTable.
NameTable nt = new NameTable();
object book = nt.Add("book");
object title = nt.Add("title");
// Create a reader that uses the NameTable.
XmlReaderSettings settings = new XmlReaderSettings();
settings.NameTable = nt;
XmlReader reader = XmlReader.Create("books.xml", settings);
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
// Cache the local name to prevent multiple calls to the LocalName property.
object localname = reader.LocalName;
// Do a comparison between the object references. This just compares pointers.
if (book == localname) {
// Add additional processing here.
}
// Do a comparison between the object references. This just compares pointers.
if (title == localname) {
// Add additional processing here.
}
}
} // End While
// Close the reader.
reader.Close();