Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 591
David Hayter Avatar asked Dec 05 '25 18:12

David Hayter


1 Answers

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);
like image 166
lucky Avatar answered Dec 07 '25 13:12

lucky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!