Updating the original question as I couldn't explain myself clearly and people focused on XML parsing instead of what I want - sorry
I have a string array which contain strings formatted like this:
A > A1 > A1-1
A > A1 > A1-2
A > A1 > A1-3
A > A2 > A2-1
A > A2 > A2-2
B > B1 > B1-1
C > C1 > C1-1
The strings actually represent a category tree like this:
A
|-- A1
| |-- A1-1
| |-- A1-2
| |-- A1-3
|
|-- A2
| |-- A2-1
| |-- A2-2
B
|-- B1
| |-- B1-1
C
|-- C1
| |-- C1-1
How can I convert that string array to a collection that actually contains categories and sub categories? I want to convert that string array to MyCategory objects and have them in a list so that I can have a product category tree.
//single category class
public class MyCategory
{
public string Title {get; set;}
public IEnumerable<MyCategory> Children {get; set;}
}