467,859 Members | 1,354 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,859 developers. It's quick & easy.

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

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(Pers on),"");

//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)

{

}

Jul 21 '05 #1
  • viewed: 4982
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by S??rgio Nunes | last post: by
1 post views Thread by Christian Schmidbauer | last post: by
3 posts views Thread by Tjerk Wolterink | last post: by
5 posts views Thread by martin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.