Select All Data from List Using Caml Query and SharePoint Web Services

  1. var arr = new Array();  
  2. var a = new ActiveXObject("Microsoft.XMLHTTP");  
  3. var id="dwt";  
  4. var listName="testlist";  
  5. var query="<query><where><gt><fieldref name="ID"><value type="Counter">0</value></fieldref></gt></where></query>";  
  6. if (a == nullreturn null;  
  7.   
  8. var getListRequest = "<!--?xml version=\"1.0\" encoding=\"utf-8\"?-->"  
  9. "<soap:envelope xmlns:xsi="\"http://www.w3.org/2001/XMLSchema-instance\"" xmlns:xsd="\"http://www.w3.org/2001/XMLSchema\"" xmlns:soap="\"http://schemas.xmlsoap.org/soap/envelope/\"">"  
  10. "<soap:body>"  
  11. "<getlistitems xmlns="\"http://schemas.microsoft.com/sharepoint/soap/\"">"  
  12. "<listname>" + listName + "</listname>"  
  13. "<query>" + query + "</query>"  
  14. "</getlistitems>"  
  15. "</soap:body>"  
  16. "</soap:envelope>";  
  17.   
  18. a.Open("Post", http://servername:100/sites/Test/_vti_bin/Lists.asmx?op=GetListItems", false);  
  19.   
  20. a.setRequestHeader("Content-Type:""text/xml; charset=utf-8");  
  21. a.setRequestHeader("SOAPAction:""http://schemas.microsoft.com/sharepoint/soap/GetListItems");  
  22. a.Send(getListRequest);  
  23. var xmlDoc = a.responseXML;