Here’s a code snippet for checking the Xml result returned from Sharepoints UpdateListItems() Lists webservice method.
private static KeyValuePair<int, string> CheckListUpdateResults(XmlNode resultsNode) { if (resultsNode == null) return new KeyValuePair<int, string>(0, "Null results node supplied"); XmlNamespaceManager ns = new XmlNamespaceManager(resultsNode.OwnerDocument.NameTable); ns.AddNamespace("sp", resultsNode.NamespaceURI); var errorCode = resultsNode.SelectSingleNode("//sp:ErrorCode", ns).InnerText; if (errorCode == "0x00000000") { // grab the list item ID var owsID = resultsNode.SelectSingleNode("//@ows_ID").Value; return new KeyValuePair<int, string>(Convert.ToInt32(owsID), null); } var errorText = resultsNode.SelectSingleNode("//sp:ErrorText", ns).InnerText; var result = new KeyValuePair<int, string>(0, string.Format("Error {0}, {1}", errorCode ?? "n/a", errorText ?? "n/a")); return result; }
This was helpful to get a decent error code back, but falls short in the case when multiple rows were updated in a single call to UpdateListItems.
In that case, the code would need to be modified to return something closer to
Collection<KeyValuePair>
I’ll leave that as an exercise for those requiring that functionailty 🙂
Thanks This is what i’m lookin for
I am getting an exception as “Object reference is not set to an instancen of object” at line
var owsID = resultsNode.SelectSingleNode(“//@ows_ID”).Value;