Click here to Skip to main content
15,895,557 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hex String into number Pin
Spacix One23-Jun-08 3:37
Spacix One23-Jun-08 3:37 
QuestionSending Text to the Active Control in the Active Application Pin
Dirso20-Jun-08 7:21
Dirso20-Jun-08 7:21 
AnswerRe: Sending Text to the Active Control in the Active Application Pin
DaveyM6920-Jun-08 11:25
professionalDaveyM6920-Jun-08 11:25 
GeneralRe: Sending Text to the Active Control in the Active Application Pin
Dirso20-Jun-08 12:48
Dirso20-Jun-08 12:48 
AnswerRe: Sending Text to the Active Control in the Active Application Pin
mav.northwind20-Jun-08 21:43
mav.northwind20-Jun-08 21:43 
QuestionUpdate Manager Pin
spelltwister20-Jun-08 7:01
spelltwister20-Jun-08 7:01 
AnswerRe: Update Manager Pin
leppie20-Jun-08 7:05
leppie20-Jun-08 7:05 
QuestionHow can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 6:58
Mohammad Dayyan20-Jun-08 6:58 
Hi all.

I have a big XML file, part of that is like this :
<FoxMark>
  <NODE ID="14" NAME="Utility" DESC="">
    <NODE ID="16" NAME="Crack" DESC="">
      <BOOKMARK ID="17" />
      <BOOKMARK ID="18" /> 
      <BOOKMARK ID="19" />
      <BOOKMARK ID="20" />
      <BOOKMARK ID="21" />
      <BOOKMARK ID="22" />
    </NODE>
  </NODE>
</FoxMark>


Now, I want select <NODE ID="16" NAME="Crack" DESC=""> and delete it by LINQ.
I wrote this method but it wasn't work perfectly :

private void Delete(string id)
        {
	    FileName = "file.xml";
            try
            {
                XElement Xelement = XElement.Load(FileName);

                var SelectedNode = from node in Xelement.Descendants("BOOKMARK")
                                   where node.Attribute("ID").Value == id
                                   select node;

                if (SelectedNode.ToList().Count == 0)
                    SelectedNode = from node in Xelement.Descendants("NODE")
                                   where node.Attribute("ID").Value == id
                                   select node;

                MessageBox.Show(SelectedNode.First().Name.ToString());

                XElement Xnode = Xelement.Element(SelectedNode.First().Name);
                Xnode.Remove();
                Xelement.Save(FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


Can you help me ?

Sorry for my English. I'm a freshman .

AnswerRe: How can we remove specific node in the XML file by LINQ? Pin
leppie20-Jun-08 7:02
leppie20-Jun-08 7:02 
GeneralRe: How can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 7:20
Mohammad Dayyan20-Jun-08 7:20 
GeneralRe: How can we remove specific node in the XML file by LINQ? Pin
leppie20-Jun-08 8:05
leppie20-Jun-08 8:05 
GeneralRe: How can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 9:09
Mohammad Dayyan20-Jun-08 9:09 
AnswerRe: How can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 9:13
Mohammad Dayyan20-Jun-08 9:13 
QuestionPacket issues Pin
see_seA20-Jun-08 5:15
see_seA20-Jun-08 5:15 
AnswerRe: Packet issues Pin
leppie20-Jun-08 5:34
leppie20-Jun-08 5:34 
AnswerRe: Packet issues Pin
leppie20-Jun-08 5:37
leppie20-Jun-08 5:37 
GeneralRe: Packet issues Pin
see_seA20-Jun-08 5:52
see_seA20-Jun-08 5:52 
GeneralRe: Packet issues Pin
see_seA20-Jun-08 6:04
see_seA20-Jun-08 6:04 
GeneralRe: Packet issues Pin
leppie20-Jun-08 7:01
leppie20-Jun-08 7:01 
GeneralRe: Packet issues Pin
see_seA20-Jun-08 7:05
see_seA20-Jun-08 7:05 
GeneralRe: Packet issues Pin
see_seA20-Jun-08 7:56
see_seA20-Jun-08 7:56 
QuestionTransparency On Parent Form . Pin
unitecsoft20-Jun-08 4:58
unitecsoft20-Jun-08 4:58 
AnswerRe: Transparency On Parent Form . Pin
see_seA20-Jun-08 5:16
see_seA20-Jun-08 5:16 
Questioninserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 4:18
laziale20-Jun-08 4:18 
AnswerRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 4:25
User 665820-Jun-08 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.