{"id":928,"date":"2019-02-27T09:50:39","date_gmt":"2019-02-27T09:50:39","guid":{"rendered":"http:\/\/blog.softreeconsulting.com\/?p=928"},"modified":"2019-02-27T09:50:39","modified_gmt":"2019-02-27T09:50:39","slug":"getting-list-properties-from-schemaxml","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/","title":{"rendered":"Getting List Properties from SchemaXml"},"content":{"rendered":"\n<p>There are many ways in CSOM to get the list properties from SharePoint site but few properties are there which we can&#8217;t get directly from list object. In this blog, I will explain how to find those using the SchemaXml.<\/p>\n\n\n\n<p>In this blog, I will explain how to find a few list properties using SchemaXml l. There are many ways in CSOM to get the properties from SharePoint list but few properties are there which we can&#8217;t get directly from list object. For example, &#8220;MajorVersionLimit&#8221; is not present directly.<\/p>\n\n\n\n<p>This below-mentioned code sample will help us to get those properties which we cannot access directly from the list object.<\/p>\n\n\n\n<p><strong><u>The code block for this is as mentioned below<\/u><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Microsoft.SharePoint.Client;\nusing System.Net;\nusing System.Security;\nusing Microsoft.SharePoint.Client.Utilities;\n\nnamespace SchemaXml\n{\nclass GetListSchema\n{\nstatic void Main(string[] args)\n{\nstring listName = &amp;amp;quot;CopyDoc&amp;amp;quot;;\nstring username = string.Empty;\nstring password = string.Empty;\nSecureString secureString = new SecureString();\nSharePointOnlineCredentials credentials = null;\nList list = null;\nSystem.Xml.Linq.XDocument xDocument;\nstring modified = string.Empty;\n\ntry\n{\nusername = &amp;amp;quot;userName@domain.com&amp;amp;quot;;\npassword = &amp;amp;quot;******&amp;amp;quot;;\n\nforeach (char ch in password.ToCharArray())\nsecureString.AppendChar(ch);\n\nClientContext ctx = new ClientContext(&amp;amp;quot;siteUrl&amp;amp;quot;); \/\/creating ClientContext from given SharePoint Site\ncredentials = new SharePointOnlineCredentials(username, secureString); \/\/creating creadential object for office365 site.\n\nctx.Credentials = credentials;\nWeb web = ctx.Web;\nlist = ctx.Web.Lists.GetByTitle(listName);\nctx.Load(list, l =&amp;amp;gt; l.SchemaXml,\nl =&amp;amp;gt; l.EnableVersioning);\nctx.ExecuteQuery();\n}\ncatch (Exception ex) { }\n\ntry\n{\nusing (System.IO.StringReader reader = new System.IO.StringReader(list.SchemaXml))\/\/getting the data from SchemaXml\n{\nxDocument = System.Xml.Linq.XDocument.Load(reader); \/\/converting StringReader to XDocument\n\nList&amp;amp;lt;ListpropertiesInfo&amp;amp;gt; listSchemaXml =\n(\nfrom l in xDocument.Descendants(&amp;amp;quot;List&amp;amp;quot;)\nselect new ListpropertiesInfo \/\/ class to store the properties\n{\nPropMajorVersionLimit = l.Attribute(&amp;amp;quot;MajorVersionLimit&amp;amp;quot;).Value,\nPropMajorWithMinorVerionLimit = l.Attribute(&amp;amp;quot;MajorWithMinorVersionsLimit&amp;amp;quot;).Value,\nPropExcludFromOfflineClient = l.Attribute(&amp;amp;quot;ExcludeFromOfflineClient&amp;amp;quot;).Value,\nPropEnableFolderCreation = l.Attribute(&amp;amp;quot;EnableFolderCreation&amp;amp;quot;).Value\n}\n).ToList();\n\nforeach (var item in listSchemaXml)\n{\nint majorVersion;\nint minorVersion;\n\nif (list.EnableVersioning)\n{\nif (Int32.TryParse(item.PropMajorVersionLimit, out majorVersion))\n{\nConsole.WriteLine(&amp;amp;quot;Major Version: &amp;amp;quot; + majorVersion);\n}\nif (Int32.TryParse(item.PropMajorWithMinorVerionLimit, out minorVersion))\n{\nConsole.WriteLine(&amp;amp;quot;Minor Version : &amp;amp;quot; + minorVersion);\n}\n}\nelse\n{\nConsole.WriteLine(&amp;amp;quot;Major Version: 0&amp;amp;quot;);\nConsole.WriteLine(&amp;amp;quot;Minor Version : 0&amp;amp;quot;);\n}\n\nif (Convert.ToBoolean(item.PropExcludFromOfflineClient))\nConsole.WriteLine(&amp;amp;quot;Status: &amp;amp;quot; + item.PropExcludFromOfflineClient);\nelse\nConsole.WriteLine(&amp;amp;quot;Status: &amp;amp;quot; + item.PropExcludFromOfflineClient);\n\nConsole.WriteLine(&amp;amp;quot;Folder Creation: &amp;amp;quot; + item.PropEnableFolderCreation);\nConsole.ReadLine();\n}\n}\n}\ncatch (Exception er) { }\n}\n\npublic class ListpropertiesInfo\n{\npublic string PropMajorVersionLimit { get; set; }\npublic string PropMajorWithMinorVerionLimit { get; set; }\npublic string PropExcludFromOfflineClient { get; set; }\npublic string PropEnableFolderCreation { get; set; }\n}\n}\n}\n<\/code><\/pre>\n\n\n\n<p>In this blog, I have explained how you can get properties of SharePoint list from SchemaXml I hope this information will help you out in a few scenarios.<\/p>\n\n\n\n<p><strong>This solution is brought to you by our SharePoint professionals.<\/strong><\/p>\n\n\n\n<p><a href=\"http:\/\/www.softreeconsulting.com\/\">Softree Technology<\/a>\u00a0employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.<\/p>\n\n\n\n<p>Be it\u00a0SPFx or SharePoint\u00a0add-in developments,\u00a0<a href=\"https:\/\/www.softreetechnology.com\/sharepoint-2019-developments\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">SharePoint 2019<\/a> developments, web part developments, migrating from SharePoint 2010\/2013 to SharePoint 2013\/2016\/Office 365, Office 365,\u00a0SharePoint hosted apps developmen<a href=\"http:\/\/www.softreeconsulting.com\/sharepoint-azure-ad\/\">t<\/a>\u00a0or something else in SharePoint, we strive to deliver the best.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many ways in CSOM to get the list properties from SharePoint site but few properties are there which we can&#8217;t get directly from list object. In this blog, I will explain how to find those using the SchemaXml. In this blog, I will explain how to find a few list properties using SchemaXml l. There are many ways [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[218,212],"class_list":["post-928","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-client-side-object-model","tag-custom-list-and-document-library"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting List Properties from SchemaXml - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting List Properties from SchemaXml - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"There are many ways in CSOM to get the list properties from SharePoint site but few properties are there which we can&#8217;t get directly from list object. In this blog, I will explain how to find those using the SchemaXml. In this blog, I will explain how to find a few list properties using SchemaXml l. There are many ways [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-27T09:50:39+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting List Properties from SchemaXml - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/","og_locale":"en_US","og_type":"article","og_title":"Getting List Properties from SchemaXml - Softree Technology","og_description":"There are many ways in CSOM to get the list properties from SharePoint site but few properties are there which we can&#8217;t get directly from list object. In this blog, I will explain how to find those using the SchemaXml. In this blog, I will explain how to find a few list properties using SchemaXml l. There are many ways [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/","og_site_name":"Softree Technology","article_published_time":"2019-02-27T09:50:39+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Getting List Properties from SchemaXml","datePublished":"2019-02-27T09:50:39+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/"},"wordCount":235,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"keywords":["Client-Side Object Model","Custom List And Document Library"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/","name":"Getting List Properties from SchemaXml - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"datePublished":"2019-02-27T09:50:39+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/getting-list-properties-from-schemaxml\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Getting List Properties from SchemaXml"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=928"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/928\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}