If I receive a string that is only a list of numbers (e.g. 1,2,3,5), is it possible to convert it to XML format, like this?
<foo>
<id>1</id>
<id>2</id>
<id>3</id>
</foo>
So far I had planned to use something along the lines of this
string s = "example";
XmlDocument xm = new XmlDocument();
xm.LoadXml(string.Format("<foo>{0}</foo>", s));
But I’m unsure as to how I should split the string so that I only get the numbers without using the obvious Split(), which is something my manager doesn’t want me to do (otherwise I’d just skip the whole XML format).
Basically, is there a way for me to ‘easily’ serialize that string into XML format?
Use
LINQtoXMLNow
elewill have the XML you are looking for