2

I have some SPLists in my SP. I take some one List like that Guid listGuid = Guid.Parse(listID); and watch id SPList list = web.Lists[listGuid];. But i don't know how i can save list in xml file in folder list?

p.s.: when i say folder list I'm talking about list.RootFolder.

0

1 Answer 1

2
String myURL = "<your site URL>/_vti_bin/owssvr.dll?Cmd=Display&List={List GUID}&XMLDATA=TRUE";
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myURL);
myRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(0);
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), enc);
string result = reader.ReadToEnd();

Source

You can chuck this URL into your browser as well and you'll get back your list data in XML. You can include the GUID of a view to filter what comes back:

http://<site url>/_vti_bin/owssvr.dll?Cmd=Display&List=<listid>&View=<view guid>&Query=*&XMLDATA=TRUE
2
  • thanks for answer, but i have one more question: for what we use View=<view guid> and what we must write there? Feb 5, 2016 at 9:36
  • Every view for a list or library has an ID. This is also called a GUID. GUIDs look something like this: {20BC0752-1B98-4647-A841-2D25780D1EB0}. To check the GUID of a view go to your list or library settings, scroll down the page and select a view, then look in the address bar. There will be a query string parameter called View with a value something like View=%7B20BC0752-1B98-4647-A841-2D25780D1EB0%7D. Note the %7B and %7D at the beginning and end are { and } respectively. Using View=<view guid> in your web service call will return XML only for those items shown in this view
    – Submits
    Feb 5, 2016 at 9:59

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.