XML reading help(urgent)

Posted on 2006-03-29
Last Modified: 2010-04-16
Here is my xml file

   <Id value="1" />
      <Type value="text" />

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();
         catch (Exception ex)
               "Error XML reading" + ex.ToString(),

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

            XmlNode TypeNode = xmlDoc.SelectSingleNode
            string Type = TypeNode.InnerText;
            MessageBox.Show("results: " + Type, Text);
         catch (Exception ex)
               "Error XML reading" + ex.ToString(),
Question by:NewMom2Brandon
    LVL 6

    Accepted Solution

    instead of string Type = TypeNode.InnerText; try

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

    Author Comment

    Yep it works. Thank you so much

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now