Advertisement

08.16.2007 at 02:40AM PDT, ID: 22766402
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

C# get XML elements by name

Asked by lambch0p in C# Programming Language, Extensible Markup Language (XML)

Tags: , , , ,

Hi,

I've written an app that dumps COM+ configuration information to an XML file.

Here's a portion of the XML file.

<applications>
  <application>
    <name>XkJlCrdGeneral</name>
    <description />
    <activation>Server</activation>
    <identity>domain\user</identity>
    <id>{111A6409-AEB4-4340-9377-76D85EBB9C51}</id>
    <applicationaccesschecks>False</applicationaccesschecks>
    <components>
      <component>
        <file>E:\folder\XkJlCrdGeneral\CRDBusinessObject.dll</file>
        <description>CRDBusinessObject.IBusinessObject</description>
      </component>
      <component>
        <file>E:\folder\XkJlCrdGeneral\CRDTradeTracker.dll</file>
        <description>CRDTradeTracker.TradeTracker</description>
      </component>
    </components>
  </application>
  <application>
    <name>Cail</name>
    <description />
    <activation>Server</activation>
    <identity>NT AUTHORITY\LOCALSERVICE</identity>
    <id>{F49C7C0E-E8DF-4CC8-8DA6-E9737992A5AA}</id>
    <applicationaccesschecks>False</applicationaccesschecks>
    <components>
      <component>
        <file>E:\folder\Cail\CAILRegistry.dll</file>
        <description>CAILRegistry.Registry</description>
      </component>
      <component>
        <file>E:\folder\Cail\StandardRegistry.dll</file>
        <description>StandardRegistry.Registry</description>
      </component>
    </components>
  </application>

My plan is to use this XML file to re-create the COM+ components on another server (to create a duplicate of that server).

I have this code to get all the <application> elements.

XmlNodeList nodes = xmlDoc.GetElementsByTagName("application");

I now want to get the data from each of the application elements and use them to set the properties of a comApplication class that i've built, so I want to do something like (this is obviously made-up):

foreach(XmlNode node in nodes)
{
   comApplication app = new comApplication();
   XmlNodeList elements = node.ChildNodes;
   app.Name = elements.GetChildNodeByName("name");//This is the bit I need to do
}

I know I can use node.ChildNodes[I] to get the elements by index, but i'd rather use Names to ensure that i'm populating my class's properties with the correct elements.

So can anyone tell me if it's possible to retrieve the child elements of a node by name?

Thanks

Mick
Start Free Trial
[+][-]08.16.2007 at 03:02AM PDT, ID: 19706570

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Extensible Markup Language (XML)
Tags: applicationaccesschecks, child, element, get, name
Sign Up Now!
Solution Provided By: carl_tawn
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.16.2007 at 04:08AM PDT, ID: 19706810

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628