Skip to content

Instantly share code, notes, and snippets.



Last active Dec 17, 2015
What would you like to do?
LINQPad snippet to read a FreeMind mind map file (.mm) and get the nested Node hierarchy. Also writes formatted lines to file (tab indented hierarchy).
void Main()
var outputPath = "Something.txt";
var inputPath = "";
var nodes = LoadFromFile(inputPath);
var lines = nodes.SelectMany(x => GetPrefixedString(x,""));
static IEnumerable<string> GetPrefixedString(Node node, string prefix){
prefix += "\t";
var nodeString = prefix + node.Text;
return nodeString
.Concat(node.Children.SelectMany(x => GetPrefixedString(x,prefix)));
static IEnumerable<Node> LoadFromFile(string filePath){
var xdoc = XDocument.Load(filePath);
var root = xdoc.Root;
if(root != null){
return root.Elements("node").Select(CreateNode);
return Enumerable.Empty<Node>();
static Node CreateNode(XElement element){
var text = "";
var textAttribute = element.Attribute("TEXT");
if(textAttribute != null){
text = textAttribute.Value;
return new Node(text){ Children = element.Elements("node").Select(CreateNode) };
class Node{
public string Text{get;set;}
public IEnumerable<Node> Children {get;set;}
public Node(string text){
Text = text;
Children = Enumerable.Empty<Node>();
public static class MyExtensions
public static IEnumerable<T> Unit<T>(this T item){
yield return item;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.