J
Julia
Hi,i am trying to DeSerialize the following class from an XML string
and i get "<root xmlns=''> was not expected."
public class Person
{
private string m_Name;
private string m_Phone;
public Person()
{
}
public string Name
{
get{return m_Name;}
set{m_Name=value;}
}
public string Phone
{
get{return m_Phone;}
set{m_Phone=value;}
}
}
This is the DeSerialize code:
Person p;
System.Xml.Serialization.XmlSerializer ser=new
System.Xml.Serialization.XmlSerializer(typeof(Person),"");
//construct the XML
string xml="<?xml version='1.0' encoding='utf-16'?>"+
"<root>"+
"<Name>Julia</Name>"+
"<Phone>00-555-555-555</Phone>"+
"</root>";
StringReader w =new StringReader(xml);
try
{
p=(Person)ser.Deserialize(w);
}
catch(Exception we)
{
}
and i get "<root xmlns=''> was not expected."
public class Person
{
private string m_Name;
private string m_Phone;
public Person()
{
}
public string Name
{
get{return m_Name;}
set{m_Name=value;}
}
public string Phone
{
get{return m_Phone;}
set{m_Phone=value;}
}
}
This is the DeSerialize code:
Person p;
System.Xml.Serialization.XmlSerializer ser=new
System.Xml.Serialization.XmlSerializer(typeof(Person),"");
//construct the XML
string xml="<?xml version='1.0' encoding='utf-16'?>"+
"<root>"+
"<Name>Julia</Name>"+
"<Phone>00-555-555-555</Phone>"+
"</root>";
StringReader w =new StringReader(xml);
try
{
p=(Person)ser.Deserialize(w);
}
catch(Exception we)
{
}