Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

GetListItems 'Query' argument is ignored

$
0
0

Folks,

I have coded the following to retrieve selected data from SharePoint using the Lists web-service. For the life of me, I can't see what is wrong with the 'Query' element syntax, but I still retrieve all elements within the list! 

Please put me out of my misery... Thanks in advance!

         private XDocument GetListData(string listID, string viewID, ListsSoapClient ws)
        {
            XDocument list_data = null;
            try
            {
                // I have tried "ows_Fullname" and "Fullname" and neither work!
                XElement query = new XElement("Query", "<Where><Eq><FieldRef Name=\"ows_Fullname\"/><Value Type=\"Text\">Fred</Value></Eq></Where>");

                list_data = XDocument.Parse(ws.GetListItems(listID, null, query, null, null, null, null).FirstNode.NextNode.ToString());

                foreach (XElement g in list_data.Elements().DescendantNodes())
                {
                    // The "ows_" prefix is required in order to display the attribute
                    Console.WriteLine(g.Attribute("ows_Fullname").Value);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                ws.Abort();
            }

            return list_data;
        }


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>