Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 23, 2014 22:05
Show Gist options
  • Save Fhernd/2fd00b6a7379355e9fb1 to your computer and use it in GitHub Desktop.
Save Fhernd/2fd00b6a7379355e9fb1 to your computer and use it in GitHub Desktop.
Exploración de nodos con XmlReader en C#.
using System;
using System.Xml;
using System.IO;
namespace Articulos.Preguntas
{
public sealed class ExploracionNodos
{
public static void Main()
{
XmlReader lectorXml = XmlReader.Create ("libros.xml");
// Este método obvia los nodos que no son parte del contenido, y pasa
// directamente a nodos de contenido:
lectorXml.MoveToContent();
while (lectorXml.Read())
{
// Muestra el contenido de todos los nodos del documento XML:
if (lectorXml.NodeType == XmlNodeType.Text)
{
Console.WriteLine (lectorXml.Value.ToString());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment