title: Finally LINQ to XML recursive viewing of elements
body: <p>I have written:</p>
  
  <pre><code>        public string GetOutline(int indentLevel, XElement element)
          {
          StringBuilder result = new StringBuilder();
  
  
          result = result.AppendLine(new string('-', indentLevel * 2) + element.Name);
  
          foreach (var childElement in element.Elements())
          {
              result.Append(GetOutline(indentLevel + 3, childElement));
          }
  
          return result.ToString();
      }
  </code></pre>
  
  <p>The result of this recursive methond run on xml file shows:</p>
  
  <pre><code>    Videos
      ------Video
      ------------Title
      ------------Director
      ------------Actors
      ------------------Actor
      ------------------Actor
      ------------------Actor
      ------------------Actor
      ------------Length
      ------------Format
      ------------Rating
      ------Video
      ------------Title
      ------------Director
      ------------Length
      ------------Format
      ------------Rating
  enter code here
  </code></pre>
  
  <p>But I would want the output to be like below: </p>
  
  <pre><code>    Videos
      ------Video
      ------------Title
      ------------Director
      ------------Actors
      ------------------Actor
      ------------Length
      ------------Format
      ------------Rating
  </code></pre>
  
  <p>How to edit the code ? Really struggling with this from yesterday ...</p>