3
在這個WS conumer C#代碼中,獲取所有列表列的最簡單方法是什麼(我只能看到10個屬性可用)並過濾一個集合ID = 3。我必須在ndViewFields中限定它們嗎?我在哪裏放置我的caml在哪裏?謝謝。SharePoint GetListItems - 獲取所有列,按集List ID過濾。 C#
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>FALSE</DateInUtc><ExpandUserField>FALSE</ExpandUserField>";
//ndViewFields.InnerXml = "<FieldRef Name='Title' /><FieldRef Name='Title' />"; //you don't need to specifically request the 'ID' column since it will be returned regardless
ndViewFields.InnerXml = "<FieldRef Name='Title' />"; //you don't need to specifically request the 'ID' column since it will be returned regardless
ndQuery.InnerXml = "<OrderBy><FieldRef Name='Title'/></OrderBy>";
try
{
XmlNode ndListItems = wList.GetListItems("MyList", string.Empty, ndQuery, ndViewFields,null, ndQueryOptions, null);
foreach (XmlNode node in ndListItems)
{
if (node.Name == "rs:data")
{
for (int f = 0; f < node.ChildNodes.Count; f++)
{
if (node.ChildNodes[f].Name == "z:row")
{
//Add the employee ID to my 'employeeIDs' ArrayList
Titles.Add(node.ChildNodes[f].Attributes["ows_Title"].Value);