Linq Return node level of hierarchical xml

Posted by Ryan on Stack Overflow See other posts from Stack Overflow or by Ryan
Published on 2010-06-16T14:08:08Z Indexed on 2010/06/16 14:12 UTC
Read the original article Hit count: 164

Filed under:
|
|

In a treeview you can retrieve the level of an item. I am trying to accomplish the same thing with the given input being an object.

The XML data I will use for this example would be something like the following

<?xml version="1.0" encoding="utf-8" ?>
<Testing>
  <Numbers>
    <Number val="1">
      <Number val="1.1">
        <Number val="1.1.1">
          <Number val="1.1.2" />
          <Number val="1.1.3" />
          <Number val="1.1.4" />
        </Number>   
      </Number>
      <Number val="1.2" />
      <Number val="1.3" />
      <Number val="1.4" />
    </Number>
    <Number val="2" />
    <Number val="3" />
    <Number val="4" />
  </Numbers>
  <Numbers>
    <Number val="5" />
    <Number val="6" />
    <Number val="7" />
    <Number val="8" />
  </Numbers>
</Testing>

This one is kicking my butt!

© Stack Overflow or respective owner

Related posts about c#

Related posts about linq-to-xml