1

I use the following code to add an item to a SP list, usign web services:

XmlNode returnValue = lists.UpdateListItems("Facturas", batchElement);
XmlNodeList errors = returnValue.SelectNodes("/Results");
if (errors.Count != 1)
{
   Console.WriteLine("errors.Count es " + errors.Count);
   Console.ReadKey();
   return -1;
}
Console.WriteLine("Error " + errors[0].Value + " -> " + int.Parse(errors[0].Value));

errors.OuterXml return the following XML(the attributes of z:row have been omitted)

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <Result ID="1,New" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    <ErrorCode>0x00000000</ErrorCode>
    <ID />
    <z:row ows_ContentTypeId="0x010031045FE2D0730F499569DE68AFDB3F0B" ... xmlns:z="#RowsetSchema" />
  </Result>
</Results>

When I run the code, I always get that errors.Count is 0. I have tried the following arguments to the SelectNodes method:

ErrorCode
//ErrorCode
/Results
Results
*[local-name() = 'ErrorCode']
/*[local-name() = 'Results']

Also, I changed my code to:

XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("soap", "http://schemas.microsoft.com/sharepoint/soap/");
nsmgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
nsmgr.AddNamespace("z", "#RowsetSchema");
XmlNode returnValue = lists.UpdateListItems("Facturas", batchElement);
XmlNodeList errors = returnValue.SelectNodes("soap:ErrorCode", nsmgr);

and did not get anything wile querying for soap:ErrorCode or rs:ErrorCode.

1 Answer 1

4
var doc = new XmlDocument();
doc.Load("1.xml");


var nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("soap", "http://schemas.microsoft.com/sharepoint/soap/");

var results = doc.SelectSingleNode("/soap:Results", nsmgr);
var errorcode = doc.SelectSingleNode("/soap:Results/soap:Result/soap:ErrorCode", nsmgr);

Console.WriteLine(errorcode.InnerText);

Sample XML:

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <Result ID="1,New" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    <ErrorCode>0x00000000</ErrorCode>
    <ID />
    <z:row ows_ContentTypeId="0x010031045FE2D0730F499569DE68AFDB3F0B" xmlns:z="#RowsetSchema" />
  </Result>
</Results>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.