Click here to Skip to main content
15,885,757 members
Home / Discussions / C#
   

C#

 
AnswerRe: Security of Passwords Pin
BobJanova28-Aug-12 23:36
BobJanova28-Aug-12 23:36 
AnswerRe: Security of Passwords Pin
Dave Kreskowiak29-Aug-12 2:06
mveDave Kreskowiak29-Aug-12 2:06 
GeneralRe: Security of Passwords Pin
Eddy Vluggen29-Aug-12 2:24
professionalEddy Vluggen29-Aug-12 2:24 
AnswerRe: Security of Passwords Pin
Pete O'Hanlon29-Aug-12 3:09
mvePete O'Hanlon29-Aug-12 3:09 
QuestionC# create folder and place documents Pin
dcof28-Aug-12 12:05
dcof28-Aug-12 12:05 
AnswerRe: C# create folder and place documents Pin
Richard Andrew x6428-Aug-12 12:57
professionalRichard Andrew x6428-Aug-12 12:57 
AnswerRe: C# create folder and place documents Pin
Wes Aday28-Aug-12 14:49
professionalWes Aday28-Aug-12 14:49 
QuestionDelete From XML File Pin
Kevin Marois28-Aug-12 10:54
professionalKevin Marois28-Aug-12 10:54 
I'v got this contacts file:

<?xml version="1.0" encoding="utf-8"?>
<Contacts>
  <Contact>
    <ContactId>0</ContactId>
    <Prefix>
    </Prefix>
    <FirstName>Kevin</FirstName>
    <MiddleName>Marois</MiddleName>
    <LastName>Brian</LastName>
    <Suffix>
    </Suffix>
    <Birthday>1965-10-11</Birthday>
    <Title>Senior Software Engineer</Title>
    <Comments>has 25 years of development experience</Comments>
  </Contact>
  <Contact>
    <ContactId>1</ContactId>
    <Prefix>Dr.</Prefix>
    <FirstName>Henry</FirstName>
    <MiddleName>DeCarlo</MiddleName>
    <LastName>G</LastName>
    <Suffix>III</Suffix>
    <Birthday>1965-10-11</Birthday>
    <Title>Oral Surgeon</Title>
    <Comments>His office is over on 23rd street</Comments>
  </Contact>
  <Contact>
    <ContactId>2</ContactId>
    <Prefix>
    </Prefix>
    <FirstName>Mattew</FirstName>
    <MiddleName>Damon</MiddleName>
    <LastName>Paige </LastName>
    <Suffix>
    </Suffix>
    <Birthday>1970-10-08</Birthday>
    <Title>Actor</Title>
    <Comments>Excellent actor</Comments>
  </Contact>
</Contacts>


I want to delete a contact given the ContactId. So far I have:

public void DeleteContact(int ContactId)
{
    XmlDocument doc = new XmlDocument();
    doc.Load(XMLFile);
    var path = "/contacts/contact[@ContactId='" + ContactId + "']";
    XmlNode t = doc.SelectSingleNode(path);
    t.ParentNode.RemoveChild(t);
    doc.Save(XMLFile);
}


But this isn't right. What's the right way to do this?

Thanks
If it's not broken, fix it until it is

AnswerRe: Delete From XML File Pin
Richard Andrew x6428-Aug-12 11:10
professionalRichard Andrew x6428-Aug-12 11:10 
GeneralRe: Delete From XML File Pin
Kevin Marois28-Aug-12 11:16
professionalKevin Marois28-Aug-12 11:16 
GeneralRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 11:36
mvePIEBALDconsult28-Aug-12 11:36 
AnswerRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 11:35
mvePIEBALDconsult28-Aug-12 11:35 
GeneralRe: Delete From XML File Pin
Kevin Marois28-Aug-12 11:47
professionalKevin Marois28-Aug-12 11:47 
GeneralRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 12:07
mvePIEBALDconsult28-Aug-12 12:07 
GeneralRe: Delete From XML File Pin
Kevin Marois28-Aug-12 12:21
professionalKevin Marois28-Aug-12 12:21 
AnswerRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 12:02
mvePIEBALDconsult28-Aug-12 12:02 
QuestionHow can I change this event handler? Pin
turbosupramk328-Aug-12 10:52
turbosupramk328-Aug-12 10:52 
AnswerRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 11:08
professionalRichard Andrew x6428-Aug-12 11:08 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 14:32
turbosupramk328-Aug-12 14:32 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 15:20
professionalRichard Andrew x6428-Aug-12 15:20 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 15:24
turbosupramk328-Aug-12 15:24 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 15:37
professionalRichard Andrew x6428-Aug-12 15:37 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 15:52
turbosupramk328-Aug-12 15:52 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 15:58
professionalRichard Andrew x6428-Aug-12 15:58 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 16:04
turbosupramk328-Aug-12 16:04 

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.