ok sorry to post again with xml question i quite new to parsing xml documents been looking through guides and stuff but can't seem to get this working so i have the following code here
public void test()
{
//elfdb = new DB_GET();
//elfdb.ParseXML(@"C:\Users\elfen\AppData\Local\PCDJ-DEX3\Database\Database.xml");
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\Users\elfen\AppData\Local\PCDJ-DEX3\Database\Database.xml");
XmlNodeList nodes = doc.SelectNodes("/database/tracks/track");
foreach (XmlNode node in nodes)
{
//string trackID = node.Attributes[0].InnerXml;
//string Artist = node.Attributes[1].InnerXml;
//string Title = node.Attributes[2].InnerXml;
string MusicPath = node.Attributes["fnam"].Value;
if (node.Attributes["arti"].Value != null)
{
Artist = node.Attributes["arti"].Value;
}
else
{
Titel = node.Attributes["titl"].Value;
paths.Add(MusicPath);
}
}
checkfiles();
}
issue im having is the Artist node keeps returning null ( yes i have looked there are a couple of songs that don't have an artist so can see why the null exception occurs )
the issue im having is i am trying to create an if function,
and i get returned null object is not an instance of an object.
tryied many ways,
node.Attributes["arti"].Value != null
bool testbool = node.Attributes["arti"].Value == 0
then passed testbool to the if statement but still same error
so thought maybe if(nodes != null)
but still the same issue does not register as a null value and was thinking not best method where i use xpath its going to never be null
so here i am again asking for guidance sorry to ask a lot of questions,
Kind Regards,
elfenliedtopfan5