I am using asp.net MVC4 Web Api.
I have set:
Dim xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter
xml.UseXmlSerializer = True
I have created a class that specifies the XML I need and this works well.
I am almost there but I am not sure how set the:
<?xml version="1.0" encoding="utf-8"?>
and how to set the element attributes:
xmlns:xsi and xsi:schemaLocation
Can I set this using an attribute?
This answer is one year delayed and tested for WebAPI2!
Enable XML declaration in your
WebApiConfig
classThen add
schemaLocation
property or member (I always prefer property)Output: