I think you are not using the appropriate data structures to solve the problem.
A two-dimensional array will not solve the problem here which boils down to parsing your songs XML file and transforming that data representation to something that you can use in C#.
I propose to represent your songs with a C# class, something like this:
[XmlRoot("SongList")]
public class SongList
{
[XmlElement("Song")]
public List<Song> Songs { get; set; }
}
public class Song
{
[XmlElement("DisplayTitle")]
public string DisplayTitle { get; set; }
[XmlElement("IsDirty")]
public bool IsDirty { get; set; }
[XmlElement("SwapLanguage")]
public bool SwapLanguage { get; set; }
[XmlElement("SongLanguage")]
public string SongLanguage { get; set; }
[XmlElement("MediaType")]
public string MediaType { get; set; }
[XmlElement("Number")]
public int Number { get; set; }
[XmlElement("SongBookName")]
public string SongBookName { get; set; }
[XmlElement("ThemeName")]
public string ThemeName { get; set; }
[XmlElement("Title")]
public string Title { get; set; }
}
Please note the use of the [XmlElement] and [XmlRoot] attributes, which allow us to specify to the XML serializer how to parse your XML representation to a C# representation of that XML.
Now using an XML string like the following :
string xml = @"<SongList>
<Song>
<DisplayTitle> Eigen bundel 10 - In Jesus name</DisplayTitle>
<IsDirty > false </IsDirty>
<SwapLanguages >false </SwapLanguages>
<SongLanguage > Both </SongLanguage >
<MediaType >Song</MediaType >
<Number>10</Number >
<SelectedVersion >MyVersion</SelectedVersion >
<SongBookName > Eigen bundel</SongBookName >
<ThemeName >OPS</ThemeName >
<Title >In Jesus name</Title>
</Song>
<Song>
<DisplayTitle > Song 2</DisplayTitle >
<IsDirty > true </IsDirty >
<SwapLanguages > false </SwapLanguages >
<SongLanguage > Both </SongLanguage >
<MediaType > Song </MediaType >
<Number > 10 </Number >
<SelectedVersion > MyVersion </SelectedVersion >
<SongBookName > Eigen bundel </SongBookName >
<ThemeName > OPS </ThemeName >
<Title > In Jesus name</Title >
</Song>
</SongList>";
You can then use the C# serializer to deserialize this XML representation to the object representation as follows:
var serializer = new XmlSerializer(typeof(SongList));
using (var reader = new StringReader(xml))
{
var albums = serializer.Deserialize(reader) as SongList;
}
If you want to read a text file you should load the file into a FileStream and deserialize it like this:
using (var fs= new FileStream("<YOUR XML FILE PATH>", FileMode.Open))
{
var songList = serializer.Deserialize(fs) as SongList;
}
Note that you should be importing the following namespaces to be able to use the XML serializer and the FileStream class :
using System.IO;
using System.Xml;
using System.Xml.Serialization;