Using (.net 2.0) I have a string in this format:



I wonder what the best (easiest) way is to get this into an xml?

I can think of 2 ways:

Method 1: - use split to get the items in an array - loop through array and build an xml string using concatenation

Method 2: - use split to get the items in an array - loops through array to build a datatable - use writexml to output xml from the datatable

The first sounds pretty simple but would require more logic to build the string.

The second seems slicker and easier to understand.

Are there other ways to do this?

+1  A: 

Instead of doing string concatenation, you could probably create an XmlDocument and stuff it with the appropriate XmlElement and XmlAttribute objects from your string... Then, write out the XmlDocument object...

Joe The Software Developer
+2  A: 
look at his sample more carefully: there's some nesting going on there this won't account for.
Joel Coehoorn
I chose this as answer because it gives me a good idea of how to start. Joe's answer also helped, but this one is more complete. And thanks to Joel for pointing out additional things to consider.