CAML Query for querying list using Title RRS feed

  • Question

  • Hi,

    I have need where I do not know the List GUID and all I can build is the list Title in my query. I would like to query a list and return all items in the list with a specific Title.

    How do I write CAML query for querying list items using list title.

    Below is the CAML query for querying list using List GUID.

        <List ID="{EE8452F8-0D35-4C24-AC49-88206198D702}" />



    Wednesday, March 15, 2017 7:04 PM

All replies

  • Hi,

    To get the list items in the list with a specific Title, we can use the code snippet below to achieve it. The "TestList" is my test list name.

    using (SPSite objSite = new SPSite("http://sp13/sites/test")) 
    	using (SPWeb objWeb = objSite.OpenWeb()) 
    		SPList spList = objWeb.Lists["TestList"];
    		SPQuery spQuery = new SPQuery();
    		spQuery.Query = @"<Query>
    								<FieldRef Name='ID' Ascending='False' /> 
    						</Query> "; 
    		SPListItemCollection spListItemCollection = spList.GetItems(spQuery); 

    If you want to achieve it in client side, we can also use Client Object model to achieve it. The following article for your reference:

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Thursday, March 16, 2017 5:10 AM