troubleshooting Question

Find element by name

Avatar of freename
freenameFlag for United States of America asked on
C#
4 Comments1 Solution569 ViewsLast Modified:
Okay, XML folks,

How do I parse through Xml file to locate a specific node. The xml file is configuration information taken from a Windows form. The information is displayed in TabPages to the user. The configuration information is written to a Config Class with public properties. The public properties get their value from the xml file.

The first level tag is constant. It will always have the value "configuration". The second level tag can change based on the TabPage Tag value. The tags, property, name, value, type will always be there.

I have the following xml example:
<configuration>   // This remains constant
   <DBSettings>   // This element name is not constant. It changes based on TabPage Tag value
      < property>   // This is constant
         <name>DBServer<\name>  // element name is constant. contains the name of a Classes property
         <value>ServerName<\value> // element name is constant. contains the value of the previous property name
         <type>System.String<\type> // element name is constant. Contains the system type for property
      <\property>
      <property>
         <name>Retain<\name>
         <value>9<\value>
         <type>System.Int32<\type>
      <\property>
   <\DBSettings>
   <OtherSettings>
      <property>
         <name>LogDirectory<\name>
         <value>C:\Logs<\value>
         <type>System.String<\type>
      <\property>
   <\OtherSettings>
<\configuration>

There will be multiple properties entries between the second level tags. And like I said, the second level tags may change their name. I need to get the value of the LogDirectory for example.
ASKER CERTIFIED SOLUTION
Dmitry G
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros