Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Title
- {
- [XmlAttribute("id")]
- public int Id { get; set; }
- public string Value { get; set; }
- }
- <Title id="123">Some Title Value</Title>
- public class Title
- {
- [XmlAttribute("id")]
- public int Id { get; set; }
- [XmlText]
- public string Value { get; set; }
- }
- <?xml version="1.0" encoding="utf-16"?>
- <Title xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- id="123"
- >Grand Poobah</Title>
- using System;
- using System.IO;
- using System.Text;
- using System.Xml.Serialization;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- var title = new Title() { Id = 3, Value = "something" };
- var serializer = new XmlSerializer(typeof(Title));
- var stream = new MemoryStream();
- serializer.Serialize(stream, title);
- stream.Flush();
- Console.Write(new string(Encoding.UTF8.GetChars(stream.GetBuffer())));
- Console.ReadLine();
- }
- }
- public class Title
- {
- [XmlAttribute("id")]
- public int Id { get; set; }
- [XmlText]
- public string Value { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement