Created
June 23, 2014 23:11
-
-
Save Fhernd/fe840151ad4bcb59293f to your computer and use it in GitHub Desktop.
Lectura de atributos de un nodo con XmlReader en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Xml; | |
using System.IO; | |
namespace Articulos.Preguntas | |
{ | |
public sealed class LecturaAtributosXML | |
{ | |
public static void Main() | |
{ | |
XmlReader lectorXml = XmlReader.Create ("almacen2.xml"); | |
while (lectorXml.Read()) | |
{ | |
// Muestra los atributos del nodo actual: | |
if (lectorXml.HasAttributes) | |
{ | |
Console.WriteLine ("Atributos de <{0}>", lectorXml.Name); | |
for (int i = 0; i < lectorXml.AttributeCount; ++i) | |
{ | |
Console.WriteLine (" {0}", lectorXml[i]); | |
} | |
} | |
// Desplaza el lector a la posición inicial: | |
lectorXml.MoveToElement(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment