Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a working Web API that receives a parameter from the https API call and performs a database lookup to get the details realting to that input parameter

The Controller that performs the lookup formats the data items that are defined in a class named Contact and returns the data as Contact

This is the resulting data that successfully arrives back on the calling browser: -
<Contact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<conID>123456</conID>
<conFirstName>John</conFirstName>
<conLastName>Doe</conLastName>
<conCompany>Acme Company</conCompany>
<conEmail>joe.doe@aacme.co.uk</conEmail>
<conTelephone1>01234567890</conTelephone1>
<conTelephone2>07764123456</conTelephone2>
<conTelephone3>02345593202</conTelephone3>
<conContact>John T Doe</conContact>
</Contact>


The header does not get displayed on the browser but it is there.

My question is how do I prevent the output from getting the xmlns data in the first XML element that should just be <contact>

What I have tried:

I have the following code in the Register Sub in WebApiConfig.vb

config.Formatters.XmlFormatter.MediaTypeMappings.Add(
New QueryStringMapping("type", "xml", New MediaTypeHeaderValue("application/xml")))

config.Formatters.XmlFormatter.UseXmlSerializer = True
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900