Handling SharePoint UpdateListItems XML Response

iceblue164

New Member
I'm inserting some items into a SharePoint 2007 list using the Lists web service. I'm trying to write some code to handle any errors reported in the response, but navigating the XML is not working as expected. I'm attempting to get a collection of Result elements, then check each Result's ErrorCode child element for an error code. When I try to get the ErrorCode of the second result, it appears to give me the first result's ErrorCode again even though I'm calling SelectSingleNode on the second Result element. What am I doing wrong? Here is my data and code (with most of the z:row attributes omitted to keep it short):SharePoint response:\[code\]- <Results xmlns="http://schemas.microsoft.com/sharepoint/soap/"> - <Result ID="1,New"> <ErrorCode>0x00000000</ErrorCode> <ID /> <z:row ows_ContentTypeId="0x0100760B0FF12756D249834F5B18A46B1A31" ows_Title="Seas-a-1-1-Target1" ows_PointID="1" ows_X_x0020_Value="http://stackoverflow.com/questions/11105953/355.000000000000" ... xmlns:z="#RowsetSchema" /> </Result> - <Result ID="2,New"> <ErrorCode>0x80020005</ErrorCode> <ErrorText>The operation failed because an unexpected error occurred. (Result Code: 0x80020005)</ErrorText> </Result> </Results>\[/code\]Code:\[code\]System.Xml.XmlNode response = listService.UpdateListItems("SCs", batchElement);XmlNamespaceManager nsm = new XmlNamespaceManager(response.OwnerDocument.NameTable);nsm.AddNamespace("sp", response.NamespaceURI);XmlNodeList results = response.SelectNodes("//sp:Result", nsm);foreach (XmlNode result in results){ System.Diagnostics.Debug.WriteLine(result.OuterXml); XmlNode node = result.SelectSingleNode("//sp:ErrorCode", nsm); System.Diagnostics.Debug.WriteLine(node.OuterXml);}\[/code\]Output:\[code\]<Result ID="1,New" xmlns="http://schemas.microsoft.com/sharepoint/soap/"><ErrorCode>0x00000000</ErrorCode><ID /><z:row ows_ContentTypeId="0x0100760B0FFF2756D249834F5B18A46B1A31" ows_Title="Seas-a-1-1-Target1" ows_PointID="1" ows_X_x0020_Value="http://stackoverflow.com/questions/11105953/355.000000000000" ... xmlns:z="#RowsetSchema" /></Result><ErrorCode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x00000000</ErrorCode><Result ID="2,New" xmlns="http://schemas.microsoft.com/sharepoint/soap/"><ErrorCode>0x80020005</ErrorCode><ErrorText>The operation failed because an unexpected error occurred. (Result Code: 0x80020005)</ErrorText></Result><ErrorCode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x00000000</ErrorCode>\[/code\]
 
Back
Top