简体   繁体   中英

XML Serialization in c# d1p1 and xmlns

When i create a new xml file, in xml's element there are things like d1p1 and xmlns and i dont want it. what should I do? this mine xml file:

<?xml version="1.0" encoding="UTF-8"?>
<f_section d1p1:id="" xmlns:d1p1="171210235434">
     <tar>01/01/2017</tar>
</f_section>

what I want to be:

<?xml version="1.0" encoding="UTF-8"?>
<f_section id="171210235434">
     <tar>01/01/2017</tar>
</f_section>

You didn't provide serializer code, try something like that to remove namespaces;

var xmlNamespace = new XmlSerializerNamespaces();
var serializer = new XmlSerializer();
xmlNamespace.Add(string.Empty, string.Empty);
//Actions
serializer.Serialize(stream, object, xmlNamespace);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM