开发者

Getting ID of newly added item into Sharepoint List from Silverlight

I am adding item into Sharepoint List from the Silverlight Application using Sharepoint' list.asmx web service. I need to know the ID of this newly created item. The UpdateListItemsCompleted's e.Result (XElement) is returned having the following XML fragment. How can I extract the ID of this item. I am not good in 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" o开发者_Go百科ws_Created="2009-12-23 14:53:55" ows_Author="3;#Khurram Aziz" ows_Editor="3;#Khurram Aziz" /> </Result> </Results>


Edit: I read the XML too hastily..

Try..

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


From top of my head try this:

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜