XPathNavigator.MoveToFollowing Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Traslada el XPathNavigator al elemento especificado en el orden del documento.
Sobrecargas
| Nombre | Description |
|---|---|
| MoveToFollowing(XPathNodeType, XPathNavigator) |
Mueve al XPathNavigator siguiente elemento del XPathNodeType especificado, al límite especificado, en orden de documento. |
| MoveToFollowing(String, String, XPathNavigator) |
Mueve al XPathNavigator elemento con el nombre local y el URI del espacio de nombres especificados, al límite especificado, en orden de documento. |
| MoveToFollowing(XPathNodeType) |
Mueve al XPathNavigator siguiente elemento del especificado en orden de XPathNodeType documento. |
| MoveToFollowing(String, String) |
Mueve al XPathNavigator elemento con el nombre local y el URI del espacio de nombres especificados en el orden del documento. |
MoveToFollowing(XPathNodeType, XPathNavigator)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
Mueve al XPathNavigator siguiente elemento del XPathNodeType especificado, al límite especificado, en orden de documento.
public:
virtual bool MoveToFollowing(System::Xml::XPath::XPathNodeType type, System::Xml::XPath::XPathNavigator ^ end);
public virtual bool MoveToFollowing(System.Xml.XPath.XPathNodeType type, System.Xml.XPath.XPathNavigator? end);
public virtual bool MoveToFollowing(System.Xml.XPath.XPathNodeType type, System.Xml.XPath.XPathNavigator end);
abstract member MoveToFollowing : System.Xml.XPath.XPathNodeType * System.Xml.XPath.XPathNavigator -> bool
override this.MoveToFollowing : System.Xml.XPath.XPathNodeType * System.Xml.XPath.XPathNavigator -> bool
Public Overridable Function MoveToFollowing (type As XPathNodeType, end As XPathNavigator) As Boolean
Parámetros
- type
- XPathNodeType
XPathNodeType del elemento . no XPathNodeType puede ser Attribute ni Namespace.
- end
- XPathNavigator
Objeto XPathNavigator situado en el límite del elemento que el actual XPathNavigator no pasará mientras busca el elemento siguiente.
Devoluciones
true es si se XPathNavigator ha movido correctamente; de lo contrario, falsees .
Ejemplos
En el ejemplo siguiente, XPathNavigator se mueve de la raíz del contosoBooks.xml archivo al elemento siguiente price . Un clon del XPathNavigator objeto se realiza mediante el Clone método . El elemento clonado XPathNavigator, situado en el price elemento, se usará como límite. Los cambios en la posición del clonado XPathNavigator no afectan al original XPathNavigator. El original XPathNavigator se mueve de nuevo a la raíz del contosoBooks.xml archivo mediante el MoveToRoot método . El título y el nombre y apellidos del autor se recuperan mediante el MoveToFollowing método y un XPathNodeType de Text. El MoveToFollowing método devolverá true hasta que se alcance el límite del price elemento.
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();
navigator.MoveToFollowing("price", "http://www.contoso.com/books");
XPathNavigator boundary = navigator.Clone();
navigator.MoveToRoot();
while (navigator.MoveToFollowing(XPathNodeType.Text, boundary))
{
Console.WriteLine(navigator.OuterXml);
}
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToFollowing("price", "http://www.contoso.com/books")
Dim boundary As XPathNavigator = navigator.Clone()
navigator.MoveToRoot()
While navigator.MoveToFollowing(XPathNodeType.Text, boundary)
Console.WriteLine(navigator.OuterXml)
End While
En el ejemplo se toma el contosoBooks.xml archivo como entrada.
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="http://www.contoso.com/books">
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
Comentarios
El MoveToFollowing método no se mueve a nodos de atributo o de espacio de nombres. Si el valor del XPathNodeType parámetro es Attribute o Namespace, el MoveToFollowing método devuelve
falsey la posición del XPathNavigator objeto no cambia.Si el XPathNavigator límite pasado como parámetro no se coloca después de la posición del actual XPathNavigator , se omite.
Si XPathNavigator el límite pasado como parámetro es
nullel siguiente nodo con el especificado XPathNodeType se encuentra en orden de documento.Los MoveToFollowing métodos no se pueden usar para mover a nodos de atributo o de espacio de nombres. Si el XPathNavigator límite pasado como parámetro se coloca sobre un nodo de atributo o espacio de nombres, es equivalente al XPathNavigator parámetro de límite que se ha colocado en el primer nodo secundario de su elemento primario. Esto garantiza que este método pueda coincidir con el elemento primario del nodo de atributo o espacio de nombres en el que se encuentra el XPathNavigator parámetro de límite.
Si el MoveToFollowing método devuelve
false, la posición de no XPathNavigator cambia.
Se aplica a
MoveToFollowing(String, String, XPathNavigator)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
Mueve al XPathNavigator elemento con el nombre local y el URI del espacio de nombres especificados, al límite especificado, en orden de documento.
public:
virtual bool MoveToFollowing(System::String ^ localName, System::String ^ namespaceURI, System::Xml::XPath::XPathNavigator ^ end);
public virtual bool MoveToFollowing(string localName, string namespaceURI, System.Xml.XPath.XPathNavigator? end);
public virtual bool MoveToFollowing(string localName, string namespaceURI, System.Xml.XPath.XPathNavigator end);
abstract member MoveToFollowing : string * string * System.Xml.XPath.XPathNavigator -> bool
override this.MoveToFollowing : string * string * System.Xml.XPath.XPathNavigator -> bool
Public Overridable Function MoveToFollowing (localName As String, namespaceURI As String, end As XPathNavigator) As Boolean
Parámetros
- localName
- String
Nombre local del elemento.
- namespaceURI
- String
Identificador URI del espacio de nombres del elemento.
- end
- XPathNavigator
Objeto XPathNavigator situado en el límite del elemento que el actual XPathNavigator no pasará mientras busca el elemento siguiente.
Devoluciones
true es si se XPathNavigator ha movido correctamente; de lo contrario, falsees .
Ejemplos
En el ejemplo siguiente, XPathNavigator se mueve de la raíz del contosoBooks.xml archivo al elemento siguiente book . Un clon del XPathNavigator objeto se realiza mediante el Clone método y se mueve del book elemento al elemento siguiente first-name . El elemento clonado XPathNavigator, situado en el first-name elemento, se usará como límite. Los cambios en la posición del clonado XPathNavigator no afectan al original XPathNavigator. A continuación, el original XPathNavigator intenta moverse al siguiente price elemento mediante el método con el MoveToFollowing límite pasado como parámetro. Se produce un error en este movimiento porque el siguiente price elemento está más allá del límite. A continuación, el original XPathNavigator intenta moverse al siguiente title elemento, que es antes del límite mediante el mismo método y se realiza correctamente.
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();
navigator.MoveToFollowing("book", "http://www.contoso.com/books");
XPathNavigator boundary = navigator.Clone();
boundary.MoveToFollowing("first-name", "http://www.contoso.com/books");
navigator.MoveToFollowing("price", "http://www.contoso.com/books", boundary);
Console.WriteLine("Position (after boundary): {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
navigator.MoveToFollowing("title", "http://www.contoso.com/books", boundary);
Console.WriteLine("Position (before boundary): {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToFollowing("book", "http://www.contoso.com/books")
Dim boundary As XPathNavigator = navigator.Clone()
boundary.MoveToFollowing("first-name", "http://www.contoso.com/books")
navigator.MoveToFollowing("price", "http://www.contoso.com/books", boundary)
Console.WriteLine("Position (after boundary): {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)
navigator.MoveToFollowing("title", "http://www.contoso.com/books", boundary)
Console.WriteLine("Position (before boundary): {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)
En el ejemplo se toma el contosoBooks.xml archivo como entrada.
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="http://www.contoso.com/books">
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
Comentarios
Si el XPathNavigator límite pasado como parámetro no se coloca después de la posición del actual XPathNavigator , se omite.
Si el XPathNavigator parámetro de límite es
null, el siguiente elemento con el nombre local y el URI del espacio de nombres especificados se encuentran en orden de documento.Los MoveToFollowing métodos no se pueden usar para mover a nodos de atributo o de espacio de nombres. Si el XPathNavigator límite pasado como parámetro se coloca sobre un nodo de atributo o espacio de nombres, es equivalente al XPathNavigator parámetro de límite que se ha colocado en el primer nodo secundario de su elemento primario. Esto garantiza que este método pueda coincidir con el elemento primario del nodo de atributo o espacio de nombres en el que se encuentra el XPathNavigator parámetro de límite.
Si el MoveToFollowing método devuelve
false, la posición de no XPathNavigator cambia.
Se aplica a
MoveToFollowing(XPathNodeType)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
Mueve al XPathNavigator siguiente elemento del especificado en orden de XPathNodeType documento.
public:
virtual bool MoveToFollowing(System::Xml::XPath::XPathNodeType type);
public virtual bool MoveToFollowing(System.Xml.XPath.XPathNodeType type);
abstract member MoveToFollowing : System.Xml.XPath.XPathNodeType -> bool
override this.MoveToFollowing : System.Xml.XPath.XPathNodeType -> bool
Public Overridable Function MoveToFollowing (type As XPathNodeType) As Boolean
Parámetros
- type
- XPathNodeType
XPathNodeType del elemento . no XPathNodeType puede ser Attribute ni Namespace.
Devoluciones
true es si se XPathNavigator ha movido correctamente; de lo contrario, falsees .
Ejemplos
En el ejemplo siguiente, XPathNavigator se mueve de la raíz del contosoBooks.xml archivo al elemento siguiente bookstore .
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();
navigator.MoveToFollowing(XPathNodeType.Element);
Console.WriteLine("Position: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToFollowing(XPathNodeType.Element)
Console.WriteLine("Position: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)
En el ejemplo se toma el contosoBooks.xml archivo como entrada.
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="http://www.contoso.com/books">
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
Comentarios
El MoveToFollowing método no se mueve a nodos de atributo o de espacio de nombres. Si el valor del XPathNodeType parámetro es Attribute o Namespace, el MoveToFollowing método devuelve
falsey la posición del XPathNavigator objeto no cambia.Si el MoveToFollowing método devuelve
false, la posición de no XPathNavigator cambia.
Se aplica a
MoveToFollowing(String, String)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
Mueve al XPathNavigator elemento con el nombre local y el URI del espacio de nombres especificados en el orden del documento.
public:
virtual bool MoveToFollowing(System::String ^ localName, System::String ^ namespaceURI);
public virtual bool MoveToFollowing(string localName, string namespaceURI);
abstract member MoveToFollowing : string * string -> bool
override this.MoveToFollowing : string * string -> bool
Public Overridable Function MoveToFollowing (localName As String, namespaceURI As String) As Boolean
Parámetros
- localName
- String
Nombre local del elemento.
- namespaceURI
- String
Identificador URI del espacio de nombres del elemento.
Devoluciones
true es si se XPathNavigator ha movido correctamente; de lo contrario, falsees .
Ejemplos
En el ejemplo siguiente, XPathNavigator se mueve de la raíz del contosoBooks.xml archivo al primer price elemento.
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();
navigator.MoveToFollowing("price", "http://www.contoso.com/books");
Console.WriteLine("Position: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()
navigator.MoveToFollowing("price", "http://www.contoso.com/books")
Console.WriteLine("Position: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)
En el ejemplo se toma el contosoBooks.xml archivo como entrada.
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns="http://www.contoso.com/books">
<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
Comentarios
Si el MoveToFollowing método devuelve false, la posición de no XPathNavigator cambia.