Ver Mensaje Individual
  #290 (permalink)  
Antiguo 08/12/2010, 18:43
mor_ohtar
 
Fecha de Ingreso: diciembre-2010
Mensajes: 1
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Factura electroncia sat mexico

Hay una forma más fácil de general el XML. Yo uso la siguiente rutina...
Código:
using (FileStream fs = File.Create(rutaFacturas))
            {
                doc = new System.Xml.XmlDocument();
                doc.LoadXml(dsFD.GetXml());
                element = doc.DocumentElement;
                nodo = element.FirstChild;
                nodo.Attributes["fecha"].Value = string.Format("{0:yyyy-MM-ddTHH:mm:ss}", Convert.ToDateTime(nodo.Attributes["fecha"].Value));

                datos = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                fs.Write(datos, 0, datos.Length);
                datos = Encoding.UTF8.GetBytes(nodo.OuterXml);
                fs.Write(datos, 0, datos.Length);
                fs.Flush();
            }