Click here to Skip to main content
15,891,529 members
Home / Discussions / C#
   

C#

 
AnswerRe: Image quality Pin
Guffa7-Jan-07 3:49
Guffa7-Jan-07 3:49 
QuestionQuestion about Page_Load event... Pin
travich6-Jan-07 20:14
travich6-Jan-07 20:14 
AnswerRe: Question about Page_Load event... Pin
Guffa7-Jan-07 4:16
Guffa7-Jan-07 4:16 
QuestionAnother Question. Pin
travich7-Jan-07 7:51
travich7-Jan-07 7:51 
GeneralRe: Another Question. Pin
Guffa7-Jan-07 9:54
Guffa7-Jan-07 9:54 
QuestionCookie-less Authentication Pin
Rahithi6-Jan-07 17:42
Rahithi6-Jan-07 17:42 
AnswerRe: Cookie-less Authentication Pin
Christian Graus6-Jan-07 20:04
protectorChristian Graus6-Jan-07 20:04 
QuestionIssues with RemoveChild() Pin
csharpk0der1236-Jan-07 17:23
csharpk0der1236-Jan-07 17: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 20:07
protectorChristian Graus6-Jan-07 20:07 
AnswerRe: Issues with RemoveChild() Pin
Luc Pattyn7-Jan-07 9:15
sitebuilderLuc Pattyn7-Jan-07 9:15 
QuestionI cant seem to think today. Pin
Captain See Sharp6-Jan-07 16:56
Captain See Sharp6-Jan-07 16:56 
AnswerRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 18:18
sitebuilderLuc Pattyn6-Jan-07 18:18 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 18:43
Captain See Sharp6-Jan-07 18:43 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 19:02
sitebuilderLuc Pattyn6-Jan-07 19:02 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 19:34
Captain See Sharp6-Jan-07 19:34 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 20:04
sitebuilderLuc Pattyn6-Jan-07 20:04 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 20:23
Captain See Sharp6-Jan-07 20:23 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 20:27
sitebuilderLuc Pattyn6-Jan-07 20:27 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 20:32
Captain See Sharp6-Jan-07 20:32 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn6-Jan-07 20:53
sitebuilderLuc Pattyn6-Jan-07 20:53 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp6-Jan-07 21:04
Captain See Sharp6-Jan-07 21:04 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn7-Jan-07 7:20
sitebuilderLuc Pattyn7-Jan-07 7:20 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp7-Jan-07 7:25
Captain See Sharp7-Jan-07 7:25 
GeneralRe: I cant seem to think today. Pin
Captain See Sharp7-Jan-07 7:34
Captain See Sharp7-Jan-07 7:34 
GeneralRe: I cant seem to think today. Pin
Luc Pattyn7-Jan-07 7:43
sitebuilderLuc Pattyn7-Jan-07 7: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.