Ver Mensaje Individual
  #10 (permalink)  
Antiguo 08/06/2012, 17:31
Ka0stj
 
Fecha de Ingreso: febrero-2010
Ubicación: México
Mensajes: 738
Antigüedad: 15 años
Puntos: 37
Respuesta: Problema para hacer split a todas las lineas de un txt c# (solo hace la pr

Podrias hacer algo como lo siguiente:

Código c#:
Ver original
  1. string xml = "";
  2.             XDocument Documento = new XDocument();
  3.  
  4.             foreach (string t in textBox1.Lines)
  5.             {
  6.                 string aux = "";
  7.                 string texto = t;
  8.                 for (int x = 0; x < texto.Length; x++)
  9.                 {
  10.                     if (texto[x] != ':')
  11.                         aux = aux + texto[x];
  12.                     else
  13.                     {
  14.  
  15.                         xml = xml + "<" + aux + "> " + texto.Substring(x + 1, (texto.Length - x) - 1) + " </" + aux + "> \r\n ";
  16.  
  17.                         Documento = new XDocument(
  18.                         new XDeclaration("1.0", "utf-8", "yes"),
  19.                         new XComment("Lista de Personas"),
  20.                         new XElement("Personas",
  21.                                             new XElement("Numero",
  22.                                                 new XAttribute("Id", "05231104"),
  23.                                                 new XElement("Nombre", "Edison García"))
  24.                                )
  25.                         );
  26.  
  27.                         break;
  28.  
  29.                     }
  30.  
  31.                      
  32.  
  33.                 }
  34.  
  35.             }
  36.             textBox2.Text = xml;
  37.  
  38.             Documento.Save("Ruta");
__________________
http://ka0stj.wordpress.com/