I'm having trouble getting my program to read this XML file properly, it will need to write to it also but not yet. Just note that this is only a little bit of the code
XmlDocument InstalledList = new XmlDocument();
InstalledList.Load(AppsInstalledFileNamePath);
//Sets the PackageNode to the correct part of the XmlDocument
XmlNodeList PackagesNode = InstalledList.GetElementsByTagName("installed");
foreach (XmlNode InstalledListNodes in PackagesNode)
{
//If the title is the same as what the user typed, continue on
if (InstalledListNodes.Attributes["title"].InnerText.Equals(packagename) == true)
{
BatchProcessFileName = InstalledListNodes.Attributes["uninstallername"].InnerText;
Console.WriteLine("Filename OK");
I also took the try statement out so I wouldn't have to add the catch
Below is the XML File that it is trying to read (and later write)
<?xml version="1.0" encoding="utf-8" ?>
<packages>
<installed>
<sampleapp title="sampleapp" id="00001" uninstallername="sampleapp.bat" installdate="11/15/09"></sampleapp>
<sampleapp2 title="sampleapp2" id="00002" uninstallername="sampleapp2.bat" installdate="11/16/09"></sampleapp2>
</installed>
<uninstalled>
</uninstalled>
</packages>
The code runs, but it has a NullReference Exception at
InstalledListNodes.Attributes["title"].InnerText.Equals(packagename) == true