Mam problem z XmlSerialize gdy chce stworzyć element root z przestrzeniom nazw on mi jej nie chce wstawić mam taki cod
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace serializatio
{
class Program
{
public static void Main(string[] args)
{
stream st = new stream();
st.from = "aaa";
st.to = "bbb";
st.version = "1.0";
st.xmlns.Add("stream", "http://xx.xx");
XmlSerializer ser = new XmlSerializer(typeof(stream), "client");
ser.Serialize(Console.Out, st, st.xmlns);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
[XmlRoot(ElementName = "stream", Namespace = "stream", IsNullable = false)]
public class stream
{
[XmlNamespaceDeclarations]
public XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
[XmlAttribute("from")]
public String from;
[XmlAttribute("to")]
public String to;
[XmlAttribute("version")]
public String version;
}
}
i otrzymuje coś takiego
<?xml version="1.0"?>
<stream xmlns:stream="http://xx.xx" from="aaa" to="bbb" version="1.0" xmlns="stream" />
a chciałbym otzrymać coś takiego
<?xml version="1.0"?>
<stream:stream xmlns:stream="http://xx.xx" from="aaa" to="bbb" version="1.0" xmlns="stream" />