I created a class from a schema using the xsd.exe tool
Now, when I serialize the class, I get extra xmlns=""on everything under the root.
<myroot xmlns="blabla">
<tag1 xmlns="">
<tag2>
...
The diagram looks like this:
<xsd:schema xmlns="blabla" targetNamespace="blabla" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MyRoot">
I see nothing in the diagram indicating that the element tag1 and below should be in a different namespace than the root.
The serialization code is simple:
MyRoot doc = new MyRoot();
...
XmlSerializer xs = new XmlSerializer(typeof(MyRoot));
MemoryStream ms = new MemoryStream();
try {
xs.Serialize(ms, doc);
The class created from xsd.exe contains only the namespace attribute in the root class.
source
share