2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by ace_almario
0

Convert your data to XML and send it to PHP.

how? can you give a sample source code please?...

0

I don't know the side of PHP but there should be enough classes to work with XML.
In this example I created a simple class called Person. This class will be serialized to an XML file called Person.xml. Most .NET objects are serializable so you can serialize almost any object, think of DataTable, DataSet etc.

Though serialization is a huge topic, here is a simple sample that can easily be modified to serialize many types of objects.

If you need your own custom class to be serialized, first create the class and mark it as Serializable:

[Serializable()]
public class Person
{
    public string FirstName;
    public string LastName;

    public Person() { }

}

Because you are writing to disk and you are going to use Xml serialization, include the following namespaces.

using System.IO;
using System.Xml.Serialization;

The following code creates the person class, then uses the filestream to create a file. Next it serializes the object and passes it to the filestream that writes the data to disk.

Person p = new Person();
p.FirstName = "Jim";
p.LastName = "Jones";
        
FileStream fs = new FileStream(@"c:\MyFolder\Person.xml", FileMode.Create);
XmlSerializer xs = new XmlSerializer(typeof(Person));
xs.Serialize(fs, p);
fs.Close();

Then you need to find the PHP code to read from it. Again (Xml)serialization is a big topic and you can customize the xml output completely. For more I information about (Xml)serializing I suggest you do some Online searching on this topic.

I hope this was helpfull

0

Thank you very much for your kind reply...
Thank very much for the sample you gave.. it helps a lot

Now I have a clue where to start studying

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.