Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

Parsing XML file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Elmo Watson - 19 Jan 2008 16:22 GMT
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?
JIGNESH - 19 Jan 2008 17:47 GMT
The Configuration API would be of help here. The WebConfigurationManager Class
from Namespace System.Web.Configuration

Examples:
http://msdn2.microsoft.com/en-us/library/system.web.configuration.webconfigurati
onmanager.aspx


AND

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/management/mgmtapi.aspx

Regards
JIGNESH

> I've got a Winforms app and I'm trying to parse an ASP.Net web.config file
> (xml)
[quoted text clipped - 20 lines]
> What can I use to show me each node, separately in the nodelist?
> Then, how can I add a node in that section?
Elmo Watson - 20 Jan 2008 05:44 GMT
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?

> The Configuration API would be of help here. The WebConfigurationManager
> Class
[quoted text clipped - 36 lines]
>> What can I use to show me each node, separately in the nodelist?
>> Then, how can I add a node in that section?
Elmo Watson - 20 Jan 2008 22:28 GMT
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?

> The Configuration API would be of help here. The WebConfigurationManager
> Class
[quoted text clipped - 36 lines]
>> What can I use to show me each node, separately in the nodelist?
>> Then, how can I add a node in that section?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.