Trying to fetch all list items from a list located in a different site collection and traverse the list items, reading some of their column values.

I've taken some code from an example snippet that claims to work just fine (at least in Firefox)

However I seems like xData.responseXML doesn't work as expected. I never get further than the line $(xData.responseXML).find("z\\:row").each(function(){ - seems like find() fails to find anything, so there are no items avaliable to traverse.

function GetTasks(siteCollection) {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
    <soapenv:Body> \
        <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
            <listName>Tasks</listName> \
            <viewFields> \
                <ViewFields> \
                    <FieldRef Name='Title' /> \
                </ViewFields> \
            </viewFields> \
        </GetListItems> \
    </soapenv:Body> \
    url: "http://" + siteCollection + "/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    contentType: "text/xml; charset=\"utf-8\"",
    complete: function(xData, status){
            var title = $(this).attr("ows_FileLeafRef").split("#")[1];
    error: function(){


I've examined the xData.responseXML object and can't seem to find any list items or any property called z:row, however I'm quite confused how this object is structured so not sure where to look.. However I've noticed that xData.responseText contains a string with all the list items I've been trying to fetch. Example of how an item is formatted <z:row ows_Title='myTitle1' ows_MetaInfo='1;#' ows__ModerationStatus='0' ows__Level='1' ows_ID='1' ows_UniqueId='1;#{1DDABC4E-C52B-4B81-B65F-50F3381B87EB}' ows_owshiddenversion='1' ows_FSObjType='1;#0' ows_Created='2012-03-12 10:59:04' ows_PermMask='0x7fffffffffffffff' ows_Modified='2012-03-12 10:59:04' ows_FileRef='1;#Lists/Tasks/1_.000' /> However I can't seem to find anything similar within xData.responseXML and I would prefer to work with XML.

4 Answers 4


Is it SharePoint 2010? Then you could use the JavaScript Client Object Model.
Example how to load list items.

  • Doh, forgot to mention that. Yes, it's SP2010, a sandboxed solution for office365. Commented Mar 28, 2012 at 8:50

Solved! Sort of... I never figured out how to get the list items from xData.responseXML. However, simply replacing it with xData.responseText instead was enough to get the code working. Now find("z\\:row") finds all the list items as expected. Works in both ie,ff and chrome.

I ended up modifying the contents of the each-loop a bit though. Here's the resulting complete-function.

complete: function (xData, status) {
        alert("fetched " + $(xData.responseText).find("z\\:row").length + " list items");
        $(xData.responseText).find("z\\:row").each(function () {
            var title = $(this).attr("ows_Title");
            alert("list item title : " + title);

If it is 2010 use Javascript Client Object Model per Matthias's answer. If it's 2007, this might make your life easier: http://spservices.codeplex.com/wikipage?title=Lists


I had a similar problem, it worked for me when I tried:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.