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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • Last Modified:

Put XML attribute values to DataSet most efficiently

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:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <rs:data ItemCount="3">
    <z:row ows_Attachments=";#http://verwaltung.mehrlandtechnik.ch/Lists/Occasionen/Attachments/5/Programming 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_UniqueId="5;#{605DFE04-59A0-4A79-A99A-6DECB3D62F02}"
    ows_FSObjType="5;#0"
    ows_Created_x0020_Date="5;#2009-12-18 15:06:13"
    ows_FileLeafRef="5;#5_.000"
    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_UniqueId="4;#{DF887B7B-ABFC-4C05-B319-B1D6E71C70ED}"
    ows_FSObjType="4;#0"
    ows_Created_x0020_Date="4;#2009-12-13 23:45:17"
    ows_FileLeafRef="4;#4_.000"
    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_UniqueId="3;#{71D0B482-446B-4737-9A1F-1C35C5124B7F}"
    ows_FSObjType="3;#0"
    ows_Created_x0020_Date="3;#2009-12-13 23:44:57"
    ows_FileLeafRef="3;#3_.000"
    ows_FileRef="3;#Lists/Occasionen/3_.000" />
  </rs:data>
</listitems>

Open in new window

0
mr-kenny
Asked:
mr-kenny
  • 2
1 Solution
 
swapneel_d14Commented:
just do dataset.readxml (filename)
0
 
mr-kennyAuthor Commented:
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
0
 
mr-kennyAuthor Commented:
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);
                listItems.Add(listItem);
            }
        }
        return listItems;
    }

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now