Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 2nd, 2007, 11:05 PM
=?Utf-8?B?RGluZXNo?=
Guest
 
Posts: n/a
Default De-serialization of existing XML

I have an XML in the following format: (sample here)

<cars>
<car name = "Ford Mustang">
<![CDATA[This is a great car.]]>
<Company>Ford</Company>
</car>
</cars>

I have written two c# classes as follows:

Class # 1 ------- car.cs

[XmlRoot("car")]
public class Car
{
private string _name = "";
private string _company= "";

[XmlAttribute("name")]
public string Name
{
get { return _name ; }
set { _name = value; }
}

[XmlElement("Company")]
public string Company
{
get { return _company; }
set { _company= value; }
}
}

Class # 2 -------cars.cs

[XmlRoot("cars")]
public class Cars
{
private car[] _car;

[XmlElement("car")]
public car[] Car
{
get { return _car; }
set { _car= value; }
}
}




The problem I an facing is as follows:

When de-serialized, the car.Name and car.Company have values. However, the
CDATA text is nowhere to be seen. Am I missing something here.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles