473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

"<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
0 5325

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ray Tayek | last post by:
hi, trying to use an xslt to make an xslt. trying something like: <?xml version="1.0" encoding="UTF-8"?> <?xmlspysamplexml H:\java\projects\spy1\spy\inputDocumentMap.xml?> <xsl:stylesheet...
2
by: S??rgio Nunes | last post by:
Hi, I'm applying a XSL transformation to a XML document. I would like to know if it's possible to include <?..?> in the output header. Example: ===== a.xml: =====
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
3
by: Tjerk Wolterink | last post by:
Hello, I've xml code that looks like this: <?xml version="1.0" encoding="ISO-8859-1"?> <xc:xcontent xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent"...
5
by: martin | last post by:
Hi, I would be extremly grateful for some help on producing an xml fragemt. The fragment that I wish to produce should look like this <Addresses> <Address>&qout;Somebody's Name&quot;...
0
by: Daniel | last post by:
hi ng, i want to invoke a dynamically created object with reflection, like: public static object createInstance(string classname, string assemblyName) { object obj=null; Assembly assembly=...
1
by: Shark Bait | last post by:
Hi, I have a web site that I am creating locally on my workstation's "C" drive. I have a reference in my web.config to a resource file (it contains global keys) using "\" as the root. Everything...
0
by: Julia | last post by:
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; ...
1
by: ismailc | last post by:
Hi, I need help please. Update system to to new version & moved on to .Net2 But now my code that worked in my .Net1 xslt does not work. .Net1 fine: <xsl:stylesheet...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.