Click here to Skip to main content
15,920,053 members
Home / Discussions / C#
   

C#

 
GeneralC# Web development Help Pin
mahesh_kumar_code3-Feb-05 19:32
mahesh_kumar_code3-Feb-05 19:32 
GeneralXML Elements Pin
John L. DeVito3-Feb-05 18:52
professionalJohn L. DeVito3-Feb-05 18:52 
GeneralRe: XML Elements Pin
Stefan Troschuetz3-Feb-05 20:53
Stefan Troschuetz3-Feb-05 20:53 
GeneralRe: XML Elements Pin
John L. DeVito3-Feb-05 22:19
professionalJohn L. DeVito3-Feb-05 22:19 
GeneralRe: XML Elements Pin
Stefan Troschuetz3-Feb-05 22:33
Stefan Troschuetz3-Feb-05 22:33 
GeneralRe: XML Elements Pin
John L. DeVito3-Feb-05 22:39
professionalJohn L. DeVito3-Feb-05 22:39 
GeneralRe: XML Elements Pin
Stefan Troschuetz3-Feb-05 22:46
Stefan Troschuetz3-Feb-05 22:46 
GeneralRe: XML Elements Pin
John L. DeVito5-Feb-05 19:13
professionalJohn L. DeVito5-Feb-05 19:13 
ok so I've done some thinking about this and here's what I've come up with. The XML file followed by Psuedo code followed by the code.

XML FIle:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<categories>
<category>Operating System</category>
<category>Productivity</category>
<category>Entertainment</category>
<category>Games</category>
<category>Misc.</category>
</categories>
<disk_numbers>
<disk>001</disk>
<disk>002</disk>
<disk>003</disk>
</disk_numbers>
</configuration>

Psuedo Code:

start in parent node "categories"
for each child node it has named "category"
check if innerText is equal to the selected item in the combo box

if it is
remove the child node
if it isn't
go to the next child node

during one pass through the child nodes this can never fail since the combo box item wouldn't be
listed if it wasn't in the file

Code:

private void mainToolbarRemoveCategoryButton_ItemClick(object sender,
DevExpress.XtraBars.ItemClickEventArgs e)
{
XmlNode parentNode = configDoc.SelectSingleNode("/configuration/categories");

if(MessageBox.Show("Are you sure?", "Katalog", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation) == DialogResult.No)
{
return;
}
else
{
foreach(XmlNode n in parentNode)
{
if(n.InnerText.ToString() == programCategoryComboBoxEdit.SelectedItem.ToString())
{
try
{
parentNode = n.ParentNode;
parentNode.RemoveChild(n);
configDoc.Save("katalog.config");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}

So hopefully it's obvious what I'm trying to do, I guess the foreach loop is where the issue is, is this how I would traverse each child node?

thanks!
GeneralRe: XML Elements Pin
Gavin Jeffrey3-Feb-05 22:01
Gavin Jeffrey3-Feb-05 22:01 
QuestionIs it possible to use XmlSerializer on a usercontrol? Pin
FocusedWolf3-Feb-05 18:02
FocusedWolf3-Feb-05 18:02 
AnswerRe: Is it possible to use XmlSerializer on a usercontrol? Pin
Gavin Jeffrey3-Feb-05 22:05
Gavin Jeffrey3-Feb-05 22:05 
AnswerRe: Is it possible to use XmlSerializer on a usercontrol? Pin
Mihail Dikov4-Feb-05 3:32
Mihail Dikov4-Feb-05 3:32 
GeneralRe: Is it possible to use XmlSerializer on a usercontrol? Pin
FocusedWolf4-Feb-05 11:38
FocusedWolf4-Feb-05 11:38 
GeneralRe: Is it possible to use XmlSerializer on a usercontrol? Pin
FocusedWolf4-Feb-05 11:39
FocusedWolf4-Feb-05 11:39 
GeneralRe: Is it possible to use XmlSerializer on a usercontrol? Pin
FocusedWolf4-Feb-05 11:56
FocusedWolf4-Feb-05 11:56 
GeneralGDI+ vs GDI Pin
Nick Z.3-Feb-05 17:58
Nick Z.3-Feb-05 17:58 
GeneralRe: GDI+ vs GDI Pin
Christian Graus4-Feb-05 18:21
protectorChristian Graus4-Feb-05 18:21 
GeneralRe: GDI+ vs GDI Pin
Nick Z.5-Feb-05 1:34
Nick Z.5-Feb-05 1:34 
GeneralDisconnected databases Pin
PaleyX3-Feb-05 16:11
PaleyX3-Feb-05 16:11 
Questionhow cd burner works? Pin
WartHog0003-Feb-05 15:38
WartHog0003-Feb-05 15:38 
GeneralPreventing automated registering Pin
Constance3-Feb-05 14:37
Constance3-Feb-05 14:37 
GeneralRe: Preventing automated registering Pin
Christian Graus3-Feb-05 14:48
protectorChristian Graus3-Feb-05 14:48 
GeneralRe: Preventing automated registering Pin
Constance3-Feb-05 22:54
Constance3-Feb-05 22:54 
GeneralRe: Preventing automated registering Pin
J4amieC4-Feb-05 3:50
J4amieC4-Feb-05 3:50 
GeneralRe: Preventing automated registering Pin
Christian Graus4-Feb-05 18:20
protectorChristian Graus4-Feb-05 18:20 

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.