时,如何摆脱的xmlns的,我不想下列附加到根元素使用XML序列化
的xmlns:XSI =“http://www.w3.org/2001/XMLSchema -instance“xmlns:xsd =”http://www.w3.org/2001/XMLSchema“>
使用XML序列化时应该怎么做。
时,如何摆脱的xmlns的,我不想下列附加到根元素使用XML序列化
的xmlns:XSI =“http://www.w3.org/2001/XMLSchema -instance“xmlns:xsd =”http://www.w3.org/2001/XMLSchema“>
使用XML序列化时应该怎么做。
通过使用Serialize方法:
public class Foo { }
class Program
{
static void Main()
{
var foo = new Foo();
var serializer = new XmlSerializer(foo.GetType());
var ns = new XmlSerializerNamespaces();
ns.Add(string.Empty, string.Empty);
serializer.Serialize(Console.Out, foo, ns);
}
}
通知的最后一个参数(ns
)。
可以请你回答这个问题:http://stackoverflow.com/questions/35034690/how-to-exclude-property-name-in-xml-serialization-in-web-api-response – user1744973 2016-01-31 06:42:43
是的,我来,等待答案! – Restuta 2010-11-17 10:30:17