XML remove child node by attribute

venbubanype

New Member
i have a xml file for my player's settings. Here is my xml file \[code\]<Player> <Volume Value="http://stackoverflow.com/questions/11504749/0,4044944" /> <Playlist> <Song Path="E:\Music\Main\Chipmunk ft. Chris Brown - Champion (Explicit Version).mp3" /> <Song Path="E:\Music\Main\Usher - More (RedOne Jimmy Joker Remix).mp3" /> </Playlist> <LastPosition LastSong="" Position="" /> </Player>\[/code\]I want to make a button which removes the node with the selected path. I have variable "path" which keeps the directory info. When i put the code :\[code\]Doc.Descendants("Song").Where(p => p.Element("Path").Value =http://stackoverflow.com/questions/11504749/= path).FirstOrDefault().Remove();\[/code\]i get a System.NullReferenceException . Can u assist me?
 
Back
Top