Open fjtello opened 7 years ago
using System.Xml; using System.Xml.Schema;
public XmlDocument GenerarContenido() { XmlDocument xmlDoc = new XmlDocument(); XmlNode header = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", string.Empty); xmlDoc.AppendChild(header); XmlElement elemRaiz; elemRaiz = xmlDoc.CreateElement(string.Empty, "RAIZ", string.Empty); xmlDoc.AppendChild(elemRaiz); XmlElement elemTexto; elemTexto = xmlDoc.CreateElement(string.Empty, "ELEMENTO", string.Empty); elemTexto.InnerText = "Contenido interno del elemento"; elemRaiz.AppendChild(elemTexto); XmlElement elemTexto2; elemTexto2 = xmlDoc.CreateElement(string.Empty, "ELEMENTO", string.Empty); elemTexto2.SetAttribute("Atributo_1", "Atributo primero del tag"); elemTexto2.SetAttribute("Atributo_2", "Atributo segundo del tag"); elemTexto2.InnerText = string.Empty; elemRaiz.AppendChild(elemTexto2); for (int ee = 0; ee < 2; ee++) { XmlElement elemInterno; elemInterno = xmlDoc.CreateElement(string.Empty, "DETALLE", string.Empty); elemInterno.InnerText = string.Format("Texto interno detalle {0}", ee.ToString()); elemTexto2.AppendChild(elemInterno); } for (int ee = 0; ee < 2; ee++) { XmlElement elemInterno; elemInterno = xmlDoc.CreateElement(string.Empty, string.Format("DETALLE_{0}", ee.ToString()), string.Empty); elemInterno.InnerText = string.Format("Texto interno detalle {0}", ee.ToString()); elemTexto2.AppendChild(elemInterno); } return xmlDoc; }
<?xml version="1.0" encoding="UTF-8"?>
using System.Xml; using System.Xml.Schema;
<?xml version="1.0" encoding="UTF-8"?>