The program I am working on is having a null reference exception whenever it tries to delete the node.
The buggy code:
First one is where the variable is declared for getting the name of the node to be deleted, just node htese are bits of the code
foreach (XmlNode InstalledListNodes in PackagesNode)
{
//If the title is the same as what the user typed, continue on
if (InstalledListNodes.Attributes["title"].Value.Equals(packagename) == true)
{
uninstallernodename = InstalledListNodes.LocalName;
Second one is where it is deleted
XmlNode PackagesListForRemoval = InstalledList.SelectSingleNode("/packages/installed/" + uninstallernodename);
PackagesListForRemoval.ParentNode.RemoveChild(PackagesListForRemoval);
InstalledList.Save("Apps.installed");
The XML File
<?xml version="1.0" encoding="utf-8" ?>
<packages>
<installed>
<sampleapp title="sampleapp" id="00001" unintallername="sampleapp.bat" installdate="11/15/09"></sampleapp>
<sampleapp2 title="sampleapp2" id="00002" uninstallername="sampleapp2.bat" installdate="11/16/09"></sampleapp2>
</installed>
<uninstalled>
</uninstalled>
</packages>