SharePoint GetListItems-获取所有列,按设置列表ID进行筛选。C#

SharePoint GetListItems-获取所有列,按设置列表ID进行筛选。C#,c#,web-services,sharepoint,list,C#,Web Services,Sharepoint,List,在这个WS-conumer C#代码中,获取所有列表列(我只看到10个可用属性)并过滤集合ID=3的最简单方法是什么。我是否必须在ndViewFields中限定所有这些字段?我应该把相机放在哪里?谢谢 XmlDocument xmlDoc = new System.Xml.XmlDocument(); XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", ""); XmlNode ndV

在这个WS-conumer C#代码中,获取所有列表列(我只看到10个可用属性)并过滤集合ID=3的最简单方法是什么。我是否必须在ndViewFields中限定所有这些字段?我应该把相机放在哪里?谢谢

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);
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=“false”;
//ndViewFields.InnerXml=“”//您不需要特别请求“ID”列,因为它将被返回
ndViewFields.InnerXml=“”//您不需要特别请求“ID”列,因为它将被返回
ndQuery.InnerXml=“”;
尝试
{
XmlNode ndListItems=wList.GetListItems(“MyList”,string.Empty,ndQuery,ndViewFields,null,ndQueryOptions,null);
foreach(ndListItems中的XmlNode节点)
{
if(node.Name==“rs:data”)
{
对于(int f=0;f
您的ndQuery应该包含:

<Query>
  <Where>
    <Eq>
      <FieldRef Name="ID" />
      <Value Type="Counter">3</Value>
    </Eq>
  </Where>
</Query>
<ViewFields>
  <FieldRef Name="ID" />
  <FieldRef Name="Title" />
  ... all other fields you need
</ViewFields>

3.
和视图字段应包含:

<Query>
  <Where>
    <Eq>
      <FieldRef Name="ID" />
      <Value Type="Counter">3</Value>
    </Eq>
  </Where>
</Query>
<ViewFields>
  <FieldRef Name="ID" />
  <FieldRef Name="Title" />
  ... all other fields you need
</ViewFields>

…您需要的所有其他字段

整个XML应该如下所示:

  <?xml version="1.0" encoding="utf-8" ?> 
 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <soap:Body>
 <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <listName>GUID Or Name</listName> 
 <query>
  <Query xmlns="">
   <Where>
    <Eq>
      <FieldRef Name="ID" /> 
      <Value Type="Counter">1</Value> 
     </Eq>
    </Where>
   </Query>
  </query>
<viewFields>
 <ViewFields xmlns="">
   <FieldRef Name="ID" /> 
   <FieldRef Name="Title" /> 
 </ViewFields>
</viewFields>
 <queryOptions>
  <QueryOptions xmlns="" /> 
  </queryOptions>
  </GetListItems>
  </soap:Body>
  </soap:Envelope>

GUID或名称
1.