reading xml with dataset

Posted on 2007-07-23
Last Modified: 2010-04-15
I am trying to read a XML file ..I am using the readxml method of the dataset..
the XML file format is as below..
it can read all the columns except the the last two with double quotes. if I rename <col type="c001"> as <col2> i can read the value properly but not can i solve the problem?

<?xml version="1.0"?>
- <securityinfo>
- <security>
  <name>U.S. - 3mo T-Bill</name>
  <col type="c001">4.825</col>
  <col type="c046">0.0</col>
Question by:saswati_m
    LVL 13

    Expert Comment

    Do you mean you want to read the attribute value? You can use an xpath expression like:


    If this is not what you want, please be more specific.

    Author Comment

    No I do not want to read the attribute values..I just need the values of the elements like 141, 4.825,0.0..It does not read the values 4.825 or 0 but it reads correctly the value is that possible ?

    I am  new to XML and would very much appreciate the help.
    LVL 13

    Expert Comment

    Can you give the xslt or xpath you're using?

    Author Comment

    I am not using any xslt path I need to use one ?  I  am not really familiar with the concept..
    I will actually be readin this file from a url..but for now I am just testing it by putting it in a file ..
    can u please explain why I need to use xpath ? can i not directly read the values from the file?
    LVL 29

    Expert Comment

    In a table in a dataset you have datatables. I believe datatables may have only unique column names that's why you are geting the error. So probably the only way to solve the problem is to rename elements.

    There are other ways to read these values,like:

    XmlDocument doc = new XmlDocument();

    XmlNodeList list = doc.GetElementsByTagName("col");
     and now you have two nodes to read from, and you can use something like:

    XmlElement elOne = (XmlElement)list[0];
    XmlElement elTwo = (XmlElement)list[1];

    string val1 = elOne.InnerText; // or InnerXml

    Author Comment

    I really appreciate your input. I used your code and it worked!!!!
    Thanks  A Lot  !!!!
    LVL 29

    Accepted Solution

    Cool! :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    760 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

    14 Experts available now in Live!

    Get 1:1 Help Now