Click here to Skip to main content
15,884,099 members
Home / Discussions / C#
   

C#

 
Questionpassing data between forms Pin
mamoony31-Aug-12 8:53
mamoony31-Aug-12 8:53 
AnswerRe: passing data between forms Pin
Richard Andrew x6431-Aug-12 9:18
professionalRichard Andrew x6431-Aug-12 9:18 
AnswerRe: passing data between forms Pin
OriginalGriff31-Aug-12 9:21
mveOriginalGriff31-Aug-12 9:21 
GeneralRe: passing data between forms Pin
mamoony31-Aug-12 10:08
mamoony31-Aug-12 10:08 
GeneralRe: passing data between forms Pin
OriginalGriff31-Aug-12 21:09
mveOriginalGriff31-Aug-12 21:09 
GeneralRe: passing data between forms Pin
BillWoodruff3-Sep-12 15:59
professionalBillWoodruff3-Sep-12 15:59 
GeneralRe: passing data between forms Pin
mamoony10-Sep-12 10:06
mamoony10-Sep-12 10:06 
QuestionDelete From XML File Pin
Kevin Marois31-Aug-12 8:47
professionalKevin Marois31-Aug-12 8:47 
I have this XML 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 using the ContactId. So far I have this:

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

    doc.Save(XMLFile);
}


But the node is coming back null. How do I delete the contact? What's wrong here?

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

AnswerRe: Delete From XML File Pin
PIEBALDconsult31-Aug-12 9:40
mvePIEBALDconsult31-Aug-12 9:40 
GeneralRe: Delete From XML File Pin
Kevin Marois31-Aug-12 9:52
professionalKevin Marois31-Aug-12 9:52 
GeneralRe: Delete From XML File Pin
PIEBALDconsult31-Aug-12 11:20
mvePIEBALDconsult31-Aug-12 11:20 
GeneralRe: Delete From XML File Pin
AmitGajjar31-Aug-12 23:27
professionalAmitGajjar31-Aug-12 23:27 
QuestionTo show the properties page of a file and navigate to a tab Pin
John T.Emmatty31-Aug-12 4:03
John T.Emmatty31-Aug-12 4:03 
AnswerRe: To show the properties page of a file and navigate to a tab Pin
Shameel31-Aug-12 4:56
professionalShameel31-Aug-12 4:56 
GeneralRe: To show the properties page of a file and navigate to a tab Pin
John T.Emmatty31-Aug-12 5:08
John T.Emmatty31-Aug-12 5:08 
AnswerRe: To show the properties page of a file and navigate to a tab Pin
Shameel31-Aug-12 5:11
professionalShameel31-Aug-12 5:11 
Question.Net C# GUI dll will use in VB6 (Not user control) Pin
mamoony31-Aug-12 3:52
mamoony31-Aug-12 3:52 
AnswerRe: .Net C# GUI dll will use in VB6 (Not user control) Pin
Shameel31-Aug-12 4:47
professionalShameel31-Aug-12 4:47 
GeneralRe: .Net C# GUI dll will use in VB6 (Not user control) Pin
mamoony31-Aug-12 7:59
mamoony31-Aug-12 7:59 
Questionhow to get difference between 2 dates in years:months format? Pin
Anurag Sinha V30-Aug-12 21:56
Anurag Sinha V30-Aug-12 21:56 
AnswerRe: how to get difference between 2 dates in years:months format? Pin
Richard MacCutchan30-Aug-12 22:36
mveRichard MacCutchan30-Aug-12 22:36 
GeneralRe: how to get difference between 2 dates in years:months format? Pin
Anurag Sinha V30-Aug-12 23:29
Anurag Sinha V30-Aug-12 23:29 
GeneralRe: how to get difference between 2 dates in years:months format? Pin
Richard MacCutchan31-Aug-12 4:11
mveRichard MacCutchan31-Aug-12 4:11 
AnswerRe: how to get difference between 2 dates in years:months format? Pin
PIEBALDconsult31-Aug-12 3:17
mvePIEBALDconsult31-Aug-12 3:17 
GeneralRe: how to get difference between 2 dates in years:months format? Pin
Marcus_231-Aug-12 3:49
Marcus_231-Aug-12 3:49 

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.