There is no "convert"; and the term itself makes no sense. There is not a predefined or "standard" way to establish correspondence between the two. There can be unlimited number of ways to create some different XMLs based on some dictionary data; there are two missing pieces of information: the required
XML schema and the set of
mapping
rules from one form of data presentation to another one. As you did not understand that it first place, to me, it means you don't really know what exactly you want. Decide it first and then find a way to explain it properly.
Better yes, learn about XML (start, for example, here:
http://en.wikipedia.org/wiki/XML[
^]) and .NET implementation of XML generation and parsing. This is my short overview of these topics:
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the classes
System.Xml.XmlTextWriter
and System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that of XmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
[EDIT]
After an OP's clarification in comments below:
If you just need to serialize/deserialize a dictionary or any other data structure, you don't need to work with XML directly (and you should not do it or apply any ad-hoc approach). Instead, use
Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[
^].
With Data Contracts, you can serialize any object graph of arbitrary topology (not just a tree, if you switch on the support of circular references). This approach is the easiest to use and the most non-intrusive: you don't change your data types to accommodate them, you just add some attributes.
I advocated this approach in some of my past answers:
How can I utilize XML File streamwriter and reader in my form application?[
^],
Creating property files...[
^].
—SA