Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Xml;
  3. using System.IO;
  4.  
  5. namespace Articulos.Preguntas
  6. {
  7.     public sealed class LecturaAtributosXML
  8.     {
  9.         public static void Main()
  10.         {
  11.             XmlReader lectorXml = XmlReader.Create ("almacen2.xml");
  12.            
  13.             while (lectorXml.Read())
  14.             {
  15.                 // Muestra los atributos del nodo actual:
  16.                 if (lectorXml.HasAttributes)
  17.                 {
  18.                     Console.WriteLine ("Atributos de <{0}>", lectorXml.Name);
  19.                    
  20.                     for (int i = 0; i < lectorXml.AttributeCount; ++i)
  21.                     {
  22.                         Console.WriteLine ("   {0}", lectorXml[i]);
  23.                     }
  24.                 }
  25.                
  26.                 // Desplaza el lector a la posiciĆ³n inicial:
  27.                 lectorXml.MoveToElement();
  28.             }
  29.         }
  30.     }
  31. }