Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I can do this XML with xmlserialization?
XML
<XML_PERS_01>
  <id value="1234567890" />
  <dati>
    <Title value="Starship Troopers" />
    <rating value="6" />
    <releasedate value="2011-09-20" />
  </dati>
</XML_PERS_01>

Thanks
Posted
Comments
kennytan_ph 5-Oct-11 8:49am    
sorry, it's not clear enough to me what you want to do.
Member 3854684 5-Oct-11 9:10am    
I wanto to write a c# class for serialize data like xml example

You have tagged this question with XmlReader, which is probably what you want to use to read your XML.

XML serialization is a way of persisting objects and retrieving them later. It is not for reading arbitrary XML files.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 13:05pm    
Good point, my 5. And I don't see no much value in custom serialization when Data Contract is available. Well, maybe something like encryption of data, compression of big volumes of data or something exotic.
--SA
you can try this classes...

[XmlRoot("XML_PERS_01")]
public class xmlClass
{
[XmlElement("id")]
public IDElement ID;
[XmlElement("dati")]
public datiElement dati;
}

public class IDElement
{
[XmlAttribute("value")]
public long value;
}

public class datiElement
{
[XmlElement("Title")]
public TitleElement Title;
[XmlElement("rating")]
public ratingElement rating;
[XmlElement("releasedate")]
public releaseDateElement;
}

public class TitleElement
{
[XmlAttribute("value")]
public string value;
}

public class ratingElement
{
[XmlAttribute("value")]
public int value;
}

public class releaseDateElement
{
[XmlAttribute("value")]
public Date Value;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900