views:

110

answers:

2

Hi, I have a simple DataContract class that contains an array of another DataContract class. When it's serialized, the resulting XML contains the array, but every tag first starts with "a:" (example: <a:name>test</a:name>). Is there a way to tell the serializer to ommit those?

Thanks!

+1  A: 

The a: is defining a XML namespace. You could probably put both Datacontracts in the same XML namespace, and the a: would disappear. Although this is still valid XML anyway.

Wagner Silveira
A: 

Specify an empty namespace for the data contracts - something like this:

[DataContract(Namespace="")]
public class YourClass
{  
  ....
}

[DataContract(Namespace="")]
public class YourArrayClass
{  
  ....
}

That should take care of it.

But why does this bother you? XML namespaces are an integral and important part of XML, especially when disambiguating XML elements from various sources.... check out W3Schools for an intro as to why XML namespaces are important and how to loose the fear of them - highly recommended!

marc_s