"<root xmlns=''> was not expected." when DeSerialize from xml string

  • Thread starter Thread starter Julia
  • Start date Start date
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)

{

}
 
* "Julia" <[email protected]> scripsit:
[...[

Just FYI: Your problem is not related to .NET Windows Forms
programming, so incldoing the Windows Forms group doesn't make much
sense.
 
Back
Top