Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I believe that creating derived properties is the best choice.</p> <p>You can design your new classes using xml schema. And then just generate the class code with <a href="http://quickstart.developerfusion.co.uk/quickstart/howto/doc/xmlserialization/XSDToCls.aspx" rel="nofollow noreferrer">xsd.exe</a>.</p> <p>With .net isn't hard to develop a generic class that can serialize and deserialize all types to and from xml.</p> <pre><code>public static String toXmlString&lt;T&gt;(T value) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); StringWriter stringWriter = new StringWriter(); try { xmlSerializer.Serialize(stringWriter, value); } catch (Exception e) { throw(e); } finally { stringWriter.Dispose(); } String xml = stringWriter.ToString(); stringWriter.Dispose(); return xml; } public static T fromXmlFile&lt;T&gt;(string fileName, Encoding encoding) { Stream stream; try { stream = File.OpenRead(fileName); } catch (Exception e) { e.Data.Add("File Name", fileName); e.Data.Add("Type", typeof(T).ToString()); throw(e); } BufferedStream bufferedStream = new BufferedStream(stream); XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); TextReader textReader; if (encoding == null) textReader = new StreamReader(bufferedStream); else textReader = new StreamReader(bufferedStream, encoding); T value; try { value = (T)xmlSerializer.Deserialize(textReader); } catch (Exception e) { e.Data.Add("File Name", fileName); e.Data.Add("Type", typeof(T).ToString()); throw(e); } finally { textReader.Dispose(); bufferedStream.Dispose(); } return value; } </code></pre>
 

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