Click here to Skip to main content
15,562,222 members
Home / Discussions / C#
   

C#

 
AnswerRe: Image quality Pin
Guffa7-Jan-07 4:49
Guffa7-Jan-07 4:49 
QuestionQuestion about Page_Load event... Pin
travich6-Jan-07 21:14
travich6-Jan-07 21:14 
AnswerRe: Question about Page_Load event... Pin
Guffa7-Jan-07 5:16
Guffa7-Jan-07 5:16 
QuestionAnother Question. Pin
travich7-Jan-07 8:51
travich7-Jan-07 8:51 
GeneralRe: Another Question. Pin
Guffa7-Jan-07 10:54
Guffa7-Jan-07 10:54 
QuestionCookie-less Authentication Pin
Rahithi6-Jan-07 18:42
Rahithi6-Jan-07 18:42 
AnswerRe: Cookie-less Authentication Pin
Christian Graus6-Jan-07 21:04
mveChristian Graus6-Jan-07 21:04 
QuestionIssues with RemoveChild() Pin
csharpk0der1236-Jan-07 18:23
csharpk0der1236-Jan-07 18:23 
Hey all,
I'm working on a small program that manipulates an XML file, like the one below:
<code><?xml version="1.0" encoding="UTF-8"?>
<Root>
<patient>
<name>Jack Sparrow</name>
<gender>female</gender>
<dob>1/1/1940</dob>
<age>67</age>
<parentsnames>n/a</parentsnames>
<maritialstatus>divorced</maritialstatus>
<streetaddress>123 Anywhere Dr</streetaddress>
<homephone>111-111-1111</homephone>
<workphone>222-222-2222</workphone>
<cellphone>333-333-3333</cellphone>
<citystatezip>Somewhere/ST/12345</citystatezip>
<iseval>1</iseval>
<dateinitialeval>1/1/2006</dateinitialeval>
<lengthinitialeval>1.4</lengthinitialeval>
<isinter>0</isinter>
<dateinitialinter>
</dateinitialinter>
<lengthinitialinter>0</lengthinitialinter>
<notes>Dr. Don</notes>
<supervisor>1</supervisor>
<attributes>
<speech>0</speech>
<language>1</language>
<articulation>0</articulation>
<hearing>1</hearing>
<tbi>0</tbi>
<cva>1</cva>
<voice>0</voice>
<fluency>0</fluency>
</attributes>
</patient>
</Root></code>
I am trying to make the script remove an old entry, then add a new entry at the end of the XML file (as you can see, this file only has one entry). I am trying to do the removing using the following code snipped:
<code> string filename = "data.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(filename);
}
catch (System.IO.FileNotFoundException)
{
//Do nothing
}
string expr = "/Root/patient[name='" + this.clientName.Text + "']";
XmlNode node;

node = xmlDoc.SelectSingleNode(expr);

node.ParentNode.RemoveChild(node);</code>
(this.clientName.Text contains the name of the client). The expression is matching just fine, if I add a MessageBox() to output node.OuterXml, everything displays fine. However, the RemoveChild() does nothing (it doesn't remove the field that was matched). The script goes on to write the edited entry, so I end up with two entries that are almost the same instead of a new one in place of an old one. What's wrong?

Let me know if you need any more information.
AnswerRe: Issues with RemoveChild() Pin
Christian Graus6-Jan-07 21:07
mveChristian Graus6-Jan-07 21:07 
AnswerRe: Issues with RemoveChild() Pin
Luc Pattyn7-Jan-07 10:15
sitebuilderLuc Pattyn7-Jan-07 10:15 
QuestionI cant seem to think today. Pin
Captain See Sharp6-Jan-07 17:56
Captain See Sharp6-Jan-07 17:56 
AnswerRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 19:18
sitebuilderLuc Pattyn6-Jan-07 19:18 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 19:43
Captain See Sharp6-Jan-07 19:43 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 20:02
sitebuilderLuc Pattyn6-Jan-07 20:02 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 20:34
Captain See Sharp6-Jan-07 20:34 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 21:04
sitebuilderLuc Pattyn6-Jan-07 21:04 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 21:23
Captain See Sharp6-Jan-07 21:23 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 21:27
sitebuilderLuc Pattyn6-Jan-07 21:27 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 21:32
Captain See Sharp6-Jan-07 21:32 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 21:53
sitebuilderLuc Pattyn6-Jan-07 21:53 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 22:04
Captain See Sharp6-Jan-07 22:04 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn7-Jan-07 8:20
sitebuilderLuc Pattyn7-Jan-07 8:20 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp7-Jan-07 8:25
Captain See Sharp7-Jan-07 8:25 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp7-Jan-07 8:34
Captain See Sharp7-Jan-07 8:34 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn7-Jan-07 8:43
sitebuilderLuc Pattyn7-Jan-07 8:43 

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.