Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

XML File Processing Question...

 

For Each Node In XmlDocument.Item("configuration").Item("appSettings")

If Node.Name.ToString = "add" Then

MsgBox(Node.Attributes.GetNamedItem("key").Value.ToString)

End If

Next Node

 

the file.

<?xml version="1.0" encoding="utf-8"?>

<configuration>

<appSettings>

<add key="inputGoogleKey.Text" value="" />

<add key="cbxBroadband.Checked" value="False" />

<add key="cbxTopMost.Checked" value="False" />

<add key="txtRecentFile0.Text" value="" />

<add key="txtRecentFile1.Text" value="" />

<add key="txtRecentFile2.Text" value="" />

<add key="txtRecentFile3.Text" value="" />

</appSettings>

</configuration>

 

What happens is that the messagebox seems to repeat the file multiple times. finally the messagebox get's weird and then it'll finally close.

 

any ideas? my brain is feeling foggy....

Posted

I created a project called "XMLProcessor", added an app.config with the info you specified in your question, then ran this code:

 

Dim Node As XmlNode

Dim XMLDocument As XmlDocument = New XmlDocument

XMLDocument.Load("XMLProcessor.exe.config")

 

For Each Node In XMLDocument.Item("configuration").Item("appSettings")

If Node.Name.ToString = "add" Then

MsgBox(Node.Attributes.GetNamedItem("key").Value.ToString)

End If

Next Node

 

 

It ran just fine - I called it in a button_click event.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...