There is an easy way to remove the namespace from the root XML element. I tried with
[XmlRootAttribute("MCP", Namespace = "", IsNullable = false)]
for a serializable class. But to no avail. still getting the same result.
sample class
[Serializable] [XmlRootAttribute("MCP", Namespace = "", IsNullable = false)] public class BINDRequest { public BINDRequest() { } [XmlAttribute] public string CLIENT_REQUEST_ID { get; set; } public BINDRequestBody BIND { get; set; } }
xml result
<?xml version="1.0" encoding="utf-8"?> <MCP xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" CLIENT_REQUEST_ID="1"> <BIND CLIENT_ID="test" PASSWORD="test" /> </MCP>
I don't understand why use namsespace hint in XmlRootAttribute?
source share