Text Field全为空格时:<Eq><FieldRef Name='TextFieldName' /><Value Type='Text'></Value></Eq>
Text Field不含任何字符时:<IsNull><FieldRef Name='TextFieldName' ></FieldRef></IsNull>,上条不成立
Text Field不区分英文大小写,这一点应该主要取决于数据库的语言设置。
User Field格式为: UserID;#UserName,如:16;#Leo Ge
如果某个字段为空,则有可能不返回该字段,对XmlNode的Attribute必须先作有效性检验,如:
if (i.Attributes.GetNamedItem("ows_Machine")!=null) taskItem.Machine = i.Attributes["ows_Machine"].Value;
GetListItems的一般性做法:
XmlDocument xmlDoc = new XmlDocument();
XmlElement query = xmlDoc.CreateElement("Query");
XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
query.InnerXml = "<Where>"
+ "<Or>"
+ "<Eq><FieldRef Name='Machine' /><Value Type='Text'>" + machineName + "</Value></Eq>"
+ "<Or>"
+ "<IsNull><FieldRef Name='Machine'></FieldRef></IsNull>"
+ "<Eq><FieldRef Name='Machine' /><Value Type='Text'></Value></Eq>"
+ "</Or>"
+ "</Or>"
+ "</Where>";
viewFields.InnerXml = "";
queryOptions.InnerXml = "";
XmlNode node = wss.GetListItems("{E7E1EEC8-F627-48A9-8228-F4BC1CA45F0C}", "{FC3C7DFF-7399-4944-A155-56AF8BCB0F11}", query, viewFields, "100", queryOptions, null);
![](/Images/OutliningIndicators/None.gif)
NameTable nt = new NameTable();
XmlNamespaceManager xnm = new XmlNamespaceManager(nt);
xnm.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
xnm.AddNamespace("z", "#RowsetSchema");
![](/Images/OutliningIndicators/None.gif)
xmlDoc = new XmlDocument();
xmlDoc.ImportNode(node,true);
![](/Images/OutliningIndicators/None.gif)
foreach (XmlNode i in node.SelectNodes("rs:data/z:row",xnm))
{
int id =int.Parse(i.Attributes["ows_ID"].Value);
string title = i.Attributes["ows_Title"].Value;
bool reloadData = i.Attributes["ows_Reload_x0020_Data"].Value == "1" ? true : false;
DateTime created = DateTime.Parse(i.Attributes["ows_Created"].Value);
string createdBy = i.Attributes["ows_Author"].Value; // 格式为userID;#userName
DateTime modified = DateTime.Parse(i.Attributes["ows_Modified"].Value);
string modifiedBy = i.Attributes["ows_Editor"].Value; // 格式为userID;#userName
EnumStatus status = (EnumStatus) Enum.Parse(typeof(EnumStatus), i.Attributes["ows_Status"].Value);
if (i.Attributes.GetNamedItem("ows_Machine")!=null) { //可能为空的字段要先作检查
string machine = i.Attributes["ows_Machine"].Value;
}
}
Text Field不含任何字符时:<IsNull><FieldRef Name='TextFieldName' ></FieldRef></IsNull>,上条不成立
Text Field不区分英文大小写,这一点应该主要取决于数据库的语言设置。
User Field格式为: UserID;#UserName,如:16;#Leo Ge
如果某个字段为空,则有可能不返回该字段,对XmlNode的Attribute必须先作有效性检验,如:
if (i.Attributes.GetNamedItem("ows_Machine")!=null) taskItem.Machine = i.Attributes["ows_Machine"].Value;
GetListItems的一般性做法:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)