Hi everybody,
give me please advice.I have proposed a class for serialization in namespace "Xml_form_application"and it looks this way:

namespace Xml_form_application
    public class RecordStore
        public MyObject MyObjectProperty;


    public class MyObject
        public string item = "thing";

 //Class form2 with button2 to calling this action
 private void button2_Click(object sender, EventArgs e)
          RecordStore pd = new RecordStore();
          TextWriter tr = new StreamWriter("C:/Users/admin/Dokumenty/Visual Studio 2010/Projects/Xml_form_application/Xml_form_application/Cvicna.xml");
          XmlSerializer sr = new XmlSerializer(typeof(RecordStore));
          sr.Serialize(tr, pd);


In input there's this xml code:

<?xml version="1.0" encoding="utf-8"?>
    <RecordStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />

I wanna to have this input with xml code (How way I can attain this result):


Is this XML file an external datasource, or is the file for local data? Serialization is a way to save states of classes. So the XML serializer will serialize with the given name space and will also import some namespaces for internal use. It was designed to save the class in it's given state - for example, you want to save the class from the memory when a computer goes on stand by.

It appears you want to use the serilized data as a data source. I would recommend building an xml file from scratch and fill it in with your class properties. Not only will you have more control on how the data is represented, it will also allow you to use the data in other applications.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.