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

ObjectXmlSelectionRouteNode

Implements: IDisposable

Members

Constructors

  • XmlSelectionRouteNode()
    Initializes a new instance of the XmlSelectionRouteNode class. (Internal use only)
  • Properties

  • BaseURI
    Gets the base URI of the current node.
    string BaseURI { get; }
  • CanBeFiltered
    Gets a value indicating whether the node can be filtered.
    bool CanBeFiltered { get; }
  • HasAttributes
    Gets a value indicating whether the node has attributes.
    bool HasAttributes { get; }
  • IsElement
    Gets a value indicating whether the node is an element.
    bool IsElement { get; }
  • IsNamespace
    Gets a value indicating whether the node is a namespace declaration.
    bool IsNamespace { get; }
  • IsText
    Gets a value indicating whether the node is a text node.
    bool IsText { get; }
  • LocalName
    Gets the local name of the node.
    string LocalName { get; }
  • Name
    Gets the qualified name of the node.
    string Name { get; }
  • NamespaceURI
    Gets the namespace URI of the node.
    string NamespaceURI { get; }
  • NodeType
    Gets the type of the node.
    System.Xml.XmlNodeType NodeType { get; }
  • Prefix
    Gets the namespace prefix of the node.
    string Prefix { get; }
  • Value
    Gets the value of the node.
    string Value { get; }
  • Methods

  • Dispose()
    Releases all resources used by the XmlSelectionRouteNode.
    void IDisposable.Dispose()
  • GetAttribute(string name)
    Gets the value of the attribute with the specified name.
    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.

  • GetAttribute(string localName, string namespaceURI)
    Gets the value of the attribute with the specified local name and namespace URI.
    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.

  • MoveToAttribute(string name)
    Moves the navigator to the attribute with the specified name.
    bool MoveToAttribute(string name)

    Parameters:

    • name: The name of the attribute.

    Returns: true if the attribute is found; otherwise, false.

  • MoveToAttribute(string localName, string namespaceURI)
    Moves the navigator to the attribute with the specified local name and namespace URI.
    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