从Silverlight获取新添加项目的ID到Sharepoint列表中

时间:2009-12-23 11:32:07

标签: silverlight sharepoint

我正在使用Sharepoint的list.asmx Web服务从Silverlight应用程序向Sharepoint List添加项目。我需要知道这个新创建的项目的ID。返回UpdateListItemsCompleted的e.Result(XElement),其中包含以下XML片段。如何提取此项目的ID。我不喜欢XLinq!

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <Result ID="1,New"> <ErrorCode>0x00000000</ErrorCode> <ID /> <z:row ows_ID="4" ows_ContentTypeId="0x010046B4975C5FD8144EBBE658917B8CB92B00EAD628BF07FAF14DA2C983B981A32E7A" ows_ContentType="Item" ows_Title="My Test Entry From Silverlight" ows_Modified="2009-12-23 14:53:55" ows_Created="2009-12-23 14:53:55" ows_Author="3;#Khurram Aziz" ows_Editor="3;#Khurram Aziz" /> </Result> </Results>

2 个答案:

答案 0 :(得分:0)

从头到尾试试这个:

using System.Xml;

XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(@"<Results xmlns=""http://schemas.microsoft.com/sharepoint/soap/""> <Result ID=""1,New""> <ErrorCode>0x00000000</ErrorCode> <ID /> <z:row ows_ID=""4"" ows_ContentTypeId=""0x010046B4975C5FD8144EBBE658917B8CB92B00EAD628BF07FAF14DA2C983B981A32E7A"" ows_ContentType=""Item"" ows_Title=""My Test Entry From Silverlight"" ows_Modified=""2009-12-23 14:53:55"" ows_Created=""2009-12-23 14:53:55"" ows_Author=""3;#Khurram Aziz"" ows_Editor=""3;#Khurram Aziz"" /> </Result> </Results>");
XmlNode xnode = xdoc.SelectSingleNode("//z:row[@ows_ID]"); //Select node that has attribute ows_ID
string idString = xnode.Attributes["ows_ID"].Value;

答案 1 :(得分:0)

编辑:我太匆忙地阅读了XML。

尝试..

           e.Result.Elements()
                    .Where(c => c.Name.LocalName == "Result").First().Elements()
                        .Where(c => element.Name.LocalName == "row").First().Attribute("ows_ID").Value;