如何在C#中将“viewfields”属性设置为true

时间:2011-12-22 18:58:24

标签: sharepoint

我正在尝试在C#中设置viewfields property = true,以便从“Getlistitems”SOAP调用返回的“ows_MetaInfo”属性中获取我需要的某些值。如果我用代码创建XML,我该怎么做呢?

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");

1 个答案:

答案 0 :(得分:3)

[MS-LISTSWS]规范说:

  

ViewFields.Properties:如果在FieldRef元素中引用了True和MetaInfo字段,则将在协议服务器响应中返回与列表项相关的属性,前缀为“ows_MetaInfo _”。

因此,您应在<FieldRef Name="MetaInfo" />元素中添加<ViewFields>