Parsing XML file

E

Elmo Watson

I've got a Winforms app and I'm trying to parse an ASP.Net web.config file
(xml)

I need to search each of the connectionstrings in the connectionstrings
section, to see if the name is there already
then, I need to write out the new node, if it's not there already

I'm having trouble figuring out how to get the child nodes, singly - here's
what I've got so far
Dim m_xmld = New System.Xml.XmlDocument
m_xmld.PreserveWhitespace = True
Dim m_nodelist As System.Xml.XmlNodeList
Dim m_node As System.Xml.XmlNode
m_xmld.Load(spath & "\web.config")
m_nodelist = m_xmld.SelectNodes("//configuration/connectionStrings")
For Each m_node In m_nodelist
MessageBox.Show(m_node.InnerXml) ' this just gives me all of
the nodes in one string - I've tried other properties, but I've been
unsuccessful
Next

Two questions:
What can I use to show me each node, separately in the nodelist?
Then, how can I add a node in that section?
 
E

Elmo Watson

I tried the first link and I can't get it to work. It seems like the IDE
doesn't recognize 'ConnectionStringsSection', and I can't find anything to
replace it with - I've imported System.Web.Configuration - done the
reference - the whole deal

According to MSDN, Web.Configuration.WebConfiguration manager:
Retrieves the specified configuration section from the current Web
application's default configuration file.
This is a Winforms app - -
none of this is recoginzed by my winforms app

This has had me working for hours and it hasn't worked - unless someonce can
give me some specific example code on how to use it, based on my stated
needs, can anyone else help, based on my original post?
 
E

Elmo Watson

Actually, I finally found a way to make the top link here work, but I can't
seem to find a way to pass a directory, so it can get a specific web.config
file to parse.
Anyone know how to add this in with it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top