Foros del Web » Programación para mayores de 30 ;) » .NET »

Guardar y leer XML.

Estas en el tema de Guardar y leer XML. en el foro de .NET en Foros del Web. Hola gente: Tengo un Form11, un button1 y otro button2 que al pulsarlo crea un XML. La idea es cómo guardar las coordenadas Location y ...
  #1 (permalink)  
Antiguo 22/05/2009, 07:12
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Guardar y leer XML.

Hola gente:

Tengo un Form11, un button1 y otro button2 que al pulsarlo crea un XML. La idea es cómo guardar las coordenadas Location y Siza del button1 en XML.

Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace Tamaño_Boton
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Location = new Point(52, 12);
            button1.Size = new Size(75, 65);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            XmlWriter w = XmlWriter.Create("Config.xml");
            w.WriteStartElement("Form1");
            w.WriteEndElement();
            w.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                XmlReader r = XmlReader.Create("Config.xml");
                r.ReadStartElement("Form1");
                r.ReadEndElement();
                r.Close();
            }
            catch
            {
                // No se encuentra el archivo.
            }
        }
    }
}
Hasta otra.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
  #2 (permalink)  
Antiguo 22/05/2009, 10:59
 
Fecha de Ingreso: abril-2007
Mensajes: 163
Antigüedad: 17 años
Puntos: 2
Respuesta: Guardar y leer XML.

En lugar de hacerlo con la clase XmlWriter, mejor hazlo con datatables , metodo xmlread y xmlwrite. Es más fácil.

saludos.
__________________
http://literaturaprogramada.blogspot.com.es/
literaturapogramada.blogspot - Reflexiones mundanas sobre la programación
  #3 (permalink)  
Antiguo 22/05/2009, 11:15
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Respuesta: Guardar y leer XML.

Buenas.

¿Hay ejemplos?

Muchas gracias amigo.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:03.