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

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)

{

}
 
H

Herfried K. Wagner [MVP]

* "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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top