SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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=''> \
    <soapenv:Body> \
        <GetListItems xmlns=''> \
            <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.

share|improve this question

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

share|improve this answer
Doh, forgot to mention that. Yes, it's SP2010, a sandboxed solution for office365. – Drkawashima Mar 28 '12 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);
share|improve this answer

If it is 2010 use Javascript Client Object Model per Matthias's answer. If it's 2007, this might make your life easier:

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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