Skip to content

Instantly share code, notes, and snippets.

@jrwren
Created August 16, 2011 15:49
Show Gist options
  • Save jrwren/1149398 to your computer and use it in GitHub Desktop.
Save jrwren/1149398 to your computer and use it in GitHub Desktop.
why not have some helpful two way XElement, strings maps :)
public static IEnumerable<System.Xml.Linq.XElement> ToXElement(this IEnumerable<string> source, string tag = "Value")
{
return source.Select(s => new System.Xml.Linq.XElement(tag, s));
}
public static IEnumerable<string> ToStrings(this System.Xml.Linq.XElement source, string tag = "Value")
{
return source.Elements("Value").Select(e => (string)e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment