Note that there are some explanatory texts on larger screens.

plurals
  1. POXML serialization options in .NET
    primarykey
    data
    text
    <p>I'm building a service that returns an XML (no SOAP, no ATOM, just plain old XML). Say that I have my domain objects already filled with data and just need to transform them to the XML format. What options do I have on .NET?</p> <p>Requirements:</p> <ul> <li>The transformation is not 1:1. Say that I have an Address property of type Address with nested properties like Line1, City, Postcode etc. This may need to result in an XML like <code>&lt;xaddr city="..."&gt;Line1, Postcode&lt;/xaddr&gt;</code>, i.e. quite different.</li> <li>Some XML elements/attributes are conditional, for example, if a Customer is under 18, the XML needs to contain some additional information.</li> <li>I only need to serialize the objects to XML, the other direction (XML to objects) is not important</li> <li>Some technologies, i.e. Data Contracts use .NET attributes. Other means of configuration (external XML config, buddy classes etc.) would be a plus.</li> </ul> <p>Here are the options as I see them as the moment. Corrections / additions will be very welcome.</p> <ul> <li>String concatenation - forget it, it was a joke :)</li> <li><strong>Linq 2 XML</strong> - complete control but quite a lot of hand written code, would need good suite of unit tests</li> <li><strong>View engines</strong> in ASP.NET MVC (or even Web Forms theoretically), the logic being in controllers. It's a question how to structure it, I can have simple rules engine in my controller(s) and one view template per each possible output, or have the decision logic directly in the template. Both have upsides and downsides.</li> <li><strong>XML Serialization</strong> - I'm not sure about the flexibility here</li> <li><strong>Data Contracts</strong> from WCF - not sure about the flexibility either, plus would they work in a simple ASP.NET MVC app (non-WCF service)? Are they a super-set of the standard XML serialization now?</li> <li>If it exists, some <strong>XML-to-object mapper</strong>. The more I think about it the more I think I'm looking for something like this but I couldn't find anything appropriate.</li> </ul> <p>Any comments / other options?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload