Friday

remove namespace xml in serialisation by XmlSerializerNamespaces.dot.net/C#/csharp


 public static string toXML(Object obj)
{
XmlSerializer xmlSerializer = new XmlSerializer(obj.GetType());
StringWriter stringWriter = new StringWriter();
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.OmitXmlDeclaration = true;
writerSettings.Indent = true;


using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, writerSettings))
{

// Namespace removed in these two lines:
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");


xmlSerializer.Serialize(xmlWriter, obj,ns);

}
return stringWriter.ToString();
}

more...

1 comment:

Anonymous said...

mil thks era presisamente o que estaba buscando!!!!

excelente!!!!!

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...