我已经使用 XmlSerializer 序列化了一个对象,并且在我的输出中收到了不需要的命名空间属性。如何防止它在 XML 中打印这些命名空间?
// write and close the bar
XmlSerializer serializer = new XmlSerializer(typeof( DecisionBar));
serializer.Serialize(writer, decision);
public class DecisionBar
{
public DateTime bartime { get; set; }
public string frequency { get; set; }
public bool HH7 { get; set; }
public bool crossover { get; set; }
public double mfe { get; set; }
public double mae { get; set; }
public double entryPointLong { get; set; }
public double entryPointShort { get; set; }
}
输出:
<DecisionBar xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<bartime>2012-07-23T07:22:00</bartime>
<frequency>1 MINUTES</frequency>
<HH7>true</HH7>
<crossover>false</crossover>
<mfe>0</mfe>
<mae>0</mae>
<entryPointLong>1.2139</entryPointLong>
<entryPointShort>1.212</entryPointShort>
</DecisionBar>