When I run my WCF REST method from the browser I receive a: in front of xml elements in when returning WCF REST service in browser? Anyone ever see this and know why it could occur? I was expecing formatted elements
<?xml version="1.0"?>
<GetProductNameListResponse xmlns="TheBigContract">
<GetProductNameListResult xmlns:i="http://www.w3.org/2001/XMLSchemaintance" xmlns:a="http://schemas.datacontract.org/2004/07/ProductDTO">
<a:Product>
<a:Company i:nil="true"/>
<a:DayOfWeek i:nil="true"/>
<a:Location i:nil="true"/>
<a:TimeOfDay i:nil="true"/>
<a:TruckID>0</a:TruckID>
<a:TruckName>BBQ Smith</a:TruckName>
<a:Website>test</a:Website>
</a:Product>
<a:Product>
<a:Company i:nil="true"/>
<a:DayOfWeek i:nil="true"/>
<a:Location i:nil="true"/>
<a:TimeOfDay i:nil="true"/>
<a:TruckID>0</a:TruckID>
<a:TruckName>Bon Me</a:TruckName>
<a:Website>test</a:Website>
</a:Product>
That is still valid XML. Your inner elements are defined in http://schemas.datacontract.org/2004/07/ProductDTO
name space and this is the way how valid XML uses elements from multiple name spaces in the same XML document. Do you see that xmlns:a=...
in GetProductNameListResult
? That defines prefix (alias) for that name space. Only elements from single name space can be without prefix (that is called default name space).
Edit: Name spaces define container where element and attribute names must be unique. But you can have multiple element types with the same name in the same XML document if they are from different name spaces. It is similar concept to .NET name spaces.
nil="true"
from the XmlSchemaInstance namespace - Sixto Saez 2012-04-05 16:31