Put XML attribute values to DataSet most efficiently

Posted on 2009-12-31
Last Modified: 2013-12-17
How do I put the attached XMLNode output most efficiently to a DataSet?

- Only <rs:data> has to be converted to DataSet
- Every <z:row> tag has to be one DataSet row
- The Attribute names of <z:row> have to be the field names of the DataSet
- The Attribute vales of <z:row> have to be the field values of the DataSet
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
  <rs:data ItemCount="3">
    <z:row ows_Attachments=";# Reference.txt;#"
    ows_LinkTitleNoMenu="Test 2" ows_Beschreibung="Text"
    ows_Created="2009-12-18 15:06:13"
    ows_Author="10;#Firstname Lastname"
    ows_Editor="10;#Firstname Lastname" ows_MetaInfo="5;#"
    ows__ModerationStatus="0" ows__Level="1" ows_Title="Test 2"
    ows_ID="5" ows_owshiddenversion="2"
    ows_Created_x0020_Date="5;#2009-12-18 15:06:13"
    ows_FileRef="5;#Lists/Occasionen/5_.000" />
    <z:row ows_Attachments="0" ows_LinkTitleNoMenu="Lorem"
    ows_Beschreibung="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
    ows_Created="2009-12-13 23:45:17"
    ows_Author="10;#Firstname Lastname"
    ows_Editor="10;#Firstname Lastname" ows_MetaInfo="4;#"
    ows__ModerationStatus="0" ows__Level="1" ows_Title="Lorem"
    ows_ID="4" ows_owshiddenversion="1"
    ows_Created_x0020_Date="4;#2009-12-13 23:45:17"
    ows_FileRef="4;#Lists/Occasionen/4_.000" />
    <z:row ows_Attachments="0" ows_LinkTitleNoMenu="Test 1"
    ows_Beschreibung="Another description."
    ows_Created="2009-12-13 23:44:57"
    ows_Author="10;#Firstname Lastname"
    ows_Editor="10;#Firstname Lastname" ows_MetaInfo="3;#"
    ows__ModerationStatus="0" ows__Level="1" ows_Title="Test 1"
    ows_ID="3" ows_owshiddenversion="1"
    ows_Created_x0020_Date="3;#2009-12-13 23:44:57"
    ows_FileRef="3;#Lists/Occasionen/3_.000" />

Open in new window

Question by:mr-kenny
    LVL 2

    Expert Comment

    just do dataset.readxml (filename)
    LVL 1

    Author Comment

    Thats's not enough: The DataSet output should consider follwing points:

    - Only <rs:data> has to be converted to DataSet
    - Every <z:row> tag has to be one DataSet row
    - The Attribute names of <z:row> have to be the field names of the DataSet
    - The Attribute vales of <z:row> have to be the field values of the DataSet
    LVL 1

    Accepted Solution

    Problem solved. I did not follow the DataSet approach any more.

    The attached code returns an ArrayList given an XMLNode of a SharePoint Web Service request.

    public static ArrayList ParseListNode(XmlNode ndListItems)
            ArrayList listItems = new ArrayList();
            XmlNodeReader xmlNodeReader = new XmlNodeReader(ndListItems);
            while (xmlNodeReader.Read())
                while (xmlNodeReader.ReadToFollowing("row", "#RowsetSchema"))
                    Dictionary<string, string> listItem = getListItem(xmlNodeReader);
            return listItems;

    Open in new window


    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    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 discusses moving either the default database or any database to a new volume.

    754 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