[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XML reading help(urgent)

Posted on 2006-03-29
2
Medium Priority
?
195 Views
Last Modified: 2010-04-16
Here is my xml file

<Config>
<PI>
   <Id value="1" />
   <Con>
      <Type value="text" />
   </Con>
 </PI>
</Config>

The XML file loads fine. However when I try ti access the value from the node. I get nothing. I need to get the word text from the Type. What am I doing wrong or missing.

         // Load XML document, loads into memory
         XmlDocument xmlDoc = new XmlDocument();
         try
         {
            xmlDoc.Load(sConfigFile);
         }
         catch (Exception ex)
         {
            System.Diagnostics.EventLog.WriteEntry(this.ToString(),
               "Error XML reading" + ex.ToString(),
               System.Diagnostics.EventLogEntryType.Error);
         }

         //read the document and pull the node into the Text box
         try
         {

            XmlNode TypeNode = xmlDoc.SelectSingleNode
           ("/Config/PI/Con/Type");
            string Type = TypeNode.InnerText;
            MessageBox.Show("results: " + Type, Text);
         }
         catch (Exception ex)
         {
            System.Diagnostics.EventLog.WriteEntry(this.ToString(),
               "Error XML reading" + ex.ToString(),
               System.Diagnostics.EventLogEntryType.Error);
         }
0
Comment
Question by:NewMom2Brandon
2 Comments
 
LVL 6

Accepted Solution

by:
e1v earned 2000 total points
ID: 16322729
instead of string Type = TypeNode.InnerText; try

string Type = TypeNode.Attributes["value"].InnerText;
0
 
LVL 2

Author Comment

by:NewMom2Brandon
ID: 16322868
Yep it works. Thank you so much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question