Overview
The XmlSelectionRouteNode class is a specialized node within the System.Xml namespace. It is designed to represent a specific node encountered during an XML selection process, often used in conjunction with XML traversal or querying mechanisms.
This class provides properties and methods to access information about the node's identity, its position in the selection path, and its relationship to other nodes in the XML document.
Syntax
public class XmlSelectionRouteNode : IDisposable
Namespace: System.Xml.XPath
Assembly: System.Xml (in System.Xml.dll)
Inheritance
Object → XmlSelectionRouteNode
Implements: IDisposable
Members
Constructors
XmlSelectionRouteNode class. (Internal use only)Properties
string BaseURI { get; }
bool CanBeFiltered { get; }
bool HasAttributes { get; }
bool IsElement { get; }
bool IsNamespace { get; }
bool IsText { get; }
string LocalName { get; }
string Name { get; }
string NamespaceURI { get; }
System.Xml.XmlNodeType NodeType { get; }
string Prefix { get; }
string Value { get; }
Methods
XmlSelectionRouteNode.void IDisposable.Dispose()
string GetAttribute(string name)
Parameters:
name: The name of the attribute to retrieve.
Returns: The value of the attribute, or null if the attribute is not found.
string GetAttribute(string localName, string namespaceURI)
Parameters:
localName: The local name of the attribute.namespaceURI: The namespace URI of the attribute.
Returns: The value of the attribute, or null if the attribute is not found.
bool MoveToAttribute(string name)
Parameters:
name: The name of the attribute.
Returns: true if the attribute is found; otherwise, false.
bool MoveToAttribute(string localName, string namespaceURI)
Parameters:
localName: The local name of the attribute.namespaceURI: The namespace URI of the attribute.
Returns: true if the attribute is found; otherwise, false.
Examples
Using XmlSelectionRouteNode with XPath
This example demonstrates how XmlSelectionRouteNode might be used internally when evaluating an XPath expression.
using System;
using System.Xml;
using System.Xml.XPath;
public class Example
{
public static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("The Great Gatsby ");
XPathNavigator navigator = doc.CreateNavigator();
// Imagine a selection process that iterates through nodes
// This is a simplified representation; actual internal workings might differ.
if (navigator.MoveToChild("books", ""))
{
if (navigator.MoveToChild("book", ""))
{
// In a real scenario, an XmlSelectionRouteNode would represent 'navigator' here
// The following is illustrative:
Console.WriteLine($"Node Name: {navigator.LocalName}"); // Output: book
Console.WriteLine($"Node Type: {navigator.NodeType}"); // Output: Element
Console.WriteLine($"Attribute 'id': {navigator.GetAttribute("id", "")}"); // Output: 1
if (navigator.MoveToChild("title", ""))
{
Console.WriteLine($"Title Text: {navigator.Value}"); // Output: The Great Gatsby
// Again, 'navigator' here would be conceptually mapped to XmlSelectionRouteNode
navigator.MoveToParent(); // Move back to 'book'
}
navigator.MoveToParent(); // Move back to 'books'
}
navigator.MoveToParent(); // Move back to document root
}
}
}
Requirements
Client compatibility: Supported in the following versions: .NET Framework 2.0, .NET Framework 3.0, .NET Framework 3.5, .NET Framework 4.0, .NET Framework 4.5, .NET Framework 4.6, .NET Framework 4.7, .NET Framework 4.8, .NET Standard 2.0, .NET Core 1.0, .NET Core 1.1, .NET Core 2.0, .NET Core 2.1, .NET Core 2.2, .NET Core 3.0, .NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8.
Platforms: Windows, Linux, macOS