kamagra how much to take

Return Your SharePoint List Items In XML

A reader (people read this crap?!?!?!) asked me how to return SharePoint list items in XML. It’s very easy!

Say you want to run a simple return with some very simple parameter types:

  1. returnListItemsXML(list.Items);

this is pretty simple! But we haven’t built the returnListItemsXML method yet :-)

Firstly, build up your method file with its name decoration and parameter types:

  1. public static XmlDocument returnListItemsXML(SPListItemCollection listItems)

You can see that we are passing in an SPListItemCollection in order to to get all the items from the relevant list (which is why in the primary method we are using list.Items).

Next, you must create a new XmlDocument object in order to represent an XML document :

  1. XmlDocument document = new XmlDocument();

Next, build a small if condition in order to check whether the the list items return a null value or not. If they do not, there is something that can be loaded into the XML document.

  1. if (listItems != null)
  2. {
  3. }

Then, load the XML document with the list items:

  1. document.LoadXml(listItems.Xml);

so, afterwords you would have this:

  1. if (listItems != null)
  2. {
  3. document.LoadXml(listItems.Xml);
  4. }

otherwise, just return the document:

  1. return document;

That’s it! Very simple indeed :-)



  1. Mun says:

    Hi, can you provide the full sample code for this? Thank you.

  2. steven says:

    Thank you for your coding,
    would you please provide the whole of the coding for me, it is interesting for this, however, how to write this coding.

  3. Mark says:

    Hi, i’m looking to do this, but am very new to c# and SahrePoint. Do you have any more information?

    Cheers keep doing what your doing!

  4. Addis Abebayehu says:

    Excellent work. Somehow, I am getting an error though! Is there something I am missing?

  5. adam says:

    You would have to say the error.


  1. Links (6/24/2007) « Steve’s SharePoint Stuff - [...] Return Your SharePoint List Items In XML [...]
  2. Bookmarks for March 8th through March 9th | Peng's Blog - [...] Return Your SharePoint List Items In XML | ARB Security Solutions – [...]

Leave a Reply

Your email address will not be published. Required fields are marked *