XML in dataset

Posted on 2011-10-07
Last Modified: 2012-05-12
  I have a xml file. I have read the xml and stored into dataset.
When I loop through all tables in dataset and get all columns in a table, I am getting strange column (Booking_Id) with some value.

Booking_Id --> Booking is the node name.

There might be many Booking nodes under <Bookings>  parent node
How is that Booking_Id is generated? On what basis a value is assigned to that Booking_Id?

Question by:rajvja
    LVL 14

    Accepted Solution

    If i remember correctly for the dataset to read the xml right it should be formatted like so:

    <?xml version="1.0" encoding="utf-8" ?>

    Open in new window

    Another option you could do thats a little slicker is utilize linq with the example below:

    public IEnumerable<XMLModel> TestXMLS()
                string filePath = HttpContext.Current.Server.MapPath(SettingsModel.XMLFileLocation + "TestXMLFile.xml");
                if (File.Exists(filePath))
                    var xml = (from x in XElement.Load(filePath).Elements("TestXMLElement") 
                               select new XMLModel
                                   ID = x.Element("ID").Value,
                                   Value = x.Element("Value").Value
                    return xml;
                    throw new Exception("File Path is invalid or file doesnt exist.");

    Open in new window

    LVL 11

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    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