2011-12-22 60 views
1

我試圖在C#中設置viewfields property = true,以獲取我從「Getlistitems」SOAP調用返回的「ows_MetaInfo」屬性中所需的某些值。如果我使用代碼創建XML,我該如何去做這件事?如何在C#中將「viewfields」屬性設置爲true#

System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); 
      System.Xml.XmlElement query = xmlDoc.CreateElement("Query"); 
      System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields"); 
      System.Xml.XmlElement rowLimit = xmlDoc.CreateElement("RowLimit"); 
      System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions"); 
      System.Xml.XmlElement webID = xmlDoc.CreateElement("WebID"); 

後先看了看http://msdn.microsoft.com/en-us/library/cc264031.aspx我試過,沒有運氣設置viewFields屬性:

System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); 
      System.Xml.XmlElement query = xmlDoc.CreateElement("Query"); 
      System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields"); 
      viewFields.SetAttribute("Properties", "True"); 
      System.Xml.XmlElement rowLimit = xmlDoc.CreateElement("RowLimit"); 
      System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions"); 
      System.Xml.XmlElement webID = xmlDoc.CreateElement("WebID"); 

回答

3

[MS-LISTSWS]規範說:

ViewFields.Properties:如果真和元信息領域在FieldRef元素中被引用,那麼在協議服務器響應中將返回與列表項有關的屬性,其前綴爲「ows_MetaInfo_」。

因此,您應該在<ViewFields>元素內包含<FieldRef Name="MetaInfo" />

相關問題