Advertisement
Milotronik

EscribirMiXMLTextWriter

Jun 7th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 3.48 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. using System.Xml;
  14. using System.Text;
  15.  
  16.  
  17. public partial class EscribirXMLTextWriter : System.Web.UI.Page
  18. {
  19.     protected void Page_Load(object sender, EventArgs e)
  20.     {
  21.         String ruta = Server.MapPath("~");
  22.         escribirXML(ruta);
  23.     }
  24.  
  25.     public void escribirXML(string ruta)
  26.     {
  27.         XmlTextWriter myXmlTextWriter = new XmlTextWriter(ruta + "\\miXmlTextWriter.xml", null);
  28.        
  29.         myXmlTextWriter.Formatting = Formatting.Indented;
  30.         myXmlTextWriter.WriteStartDocument(false);
  31.  
  32.         myXmlTextWriter.WriteStartElement("empleados");
  33.             myXmlTextWriter.WriteStartElement("listado");
  34.                 myXmlTextWriter.WriteStartElement("empleado");
  35.                     myXmlTextWriter.WriteElementString("id", "4884");
  36.                     myXmlTextWriter.WriteElementString("nombreCompleto", "Rodriguez, Victor");
  37.                     myXmlTextWriter.WriteElementString("cuit", "20103180326");
  38.                     myXmlTextWriter.WriteStartElement("sector");
  39.                         myXmlTextWriter.WriteAttributeString("denominacion", "Gerencia Recursos Humanos");
  40.                         myXmlTextWriter.WriteAttributeString("id", "137");
  41.                         myXmlTextWriter.WriteAttributeString("valorSemaforo", "130.13");
  42.                         myXmlTextWriter.WriteAttributeString("colorSemaforo", "VERDE");
  43.                         myXmlTextWriter.WriteEndElement();
  44.                     myXmlTextWriter.WriteElementString("cupoAsignado", "1837.15");
  45.                     myXmlTextWriter.WriteElementString("cupoConsumido", "658.02");
  46.                 myXmlTextWriter.WriteEndElement();
  47.             myXmlTextWriter.Flush();
  48.                 myXmlTextWriter.WriteStartElement("empleado");
  49.                     myXmlTextWriter.WriteElementString("id", "1225");
  50.                     myXmlTextWriter.WriteElementString("nombreCompleto", "Sanchez, Juan Ignacio");
  51.                     myXmlTextWriter.WriteElementString("cuit", "20271265817");
  52.                     myXmlTextWriter.WriteStartElement("sector");
  53.                         myXmlTextWriter.WriteAttributeString("denominacion", "Gerencia Operativa");
  54.                         myXmlTextWriter.WriteAttributeString("id", "44");
  55.                         myXmlTextWriter.WriteAttributeString("valorSemaforo", "130.13");
  56.                         myXmlTextWriter.WriteAttributeString("colorSemaforo", "ROJO");
  57.                         myXmlTextWriter.WriteEndElement();
  58.                     myXmlTextWriter.WriteElementString("cupoAsignado", "750.87");
  59.                     myXmlTextWriter.WriteElementString("cupoConsumido", "625.46");
  60.                 myXmlTextWriter.WriteEndElement();
  61.             myXmlTextWriter.WriteEndElement();
  62.             myXmlTextWriter.WriteElementString("subsectores", "5");
  63.             myXmlTextWriter.WriteElementString("totalCupoAsignadoSector", "4217.21");
  64.             myXmlTextWriter.WriteElementString("totalCupoConsumidoSector", "1405.88");
  65.             myXmlTextWriter.WriteElementString("valorDial", "33.34");
  66.         myXmlTextWriter.WriteEndElement();
  67.        
  68.        
  69.  
  70.         myXmlTextWriter.Flush();
  71.         myXmlTextWriter.Close();
  72.         Console.ReadLine();
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement