从 SharePoint 获取Listitems 结果?
GetListitems Web 服务依赖 XML 从 SharePoint 检索数据。
一些实际的工作代码是:
var doc = new XmlDocument();
doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"DeliveryStatus\" /><Value Type=\"Text\">Created</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
XmlNode items = wsLists.GetListItems(ListName, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, null);
一旦 XMLNode 被填充,是否有一种经过尝试和测试的方法来遍历子节点的集合?
我知道如何使用 .net 通用技术来做到这一点,但令我担心的是,可能存在一些我不知道的陷阱。例如,我注意到在我的一些测试中,firstChild 和lastChild 是空的。我想知道这是否是一个例外而不是规则。从 MSDN 文档中不可能知道,所以如果你们中有人有这方面的经验,请分享。
提前致谢
The GetListitems web service relies on XML to retrieve data from SharePoint.
Some actual working code is:
var doc = new XmlDocument();
doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"DeliveryStatus\" /><Value Type=\"Text\">Created</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
XmlNode items = wsLists.GetListItems(ListName, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, null);
Once XMLNode is populated, is there a tried and tested way to traverse the collection of childnodes?
I know how to do this using .net general techniques, but what concerns me is that there might be some pitfalls I am unaware of. For example, I noticed the firstChild and lastChild are empty during some of my tests. I wonder if this is an exception rather than a rule. Its impossible to know from MSDN documentation, so if any of you guys have experience with this please share.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的意思是 FirstChild 和 LastChild 有时是空的?好吧,如果您有诸如
之类的标签,那么这意味着它们没有孩子。按照逻辑,我猜这些属性肯定是空的。或者除此之外还有其他问题吗?
You mean FirstChild and LastChild sometimes are empty? Well, if you have tags like
<QueryOptions />
and such, then it means they have no childs. By logic I guess that those properties must be empty then.Or is there any other problem than that?