views:

28

answers:

0

Hello...

i want to add a item to a Sharepoint 2010 custom List over WebService. I can read data but i can't write.

i test this code, i had no Error but no new item is in the List:

  XElement batch = new XElement("Batch",
            "<Batch OnError=\"Continue\">"
                + "<Method ID=\"1\" Cmd=\"New\">"
                    + "<Field Name=\"Title\">Hello</Field>"
                + "</Method>"
            +"</Batch>");

        client.UpdateListItemsCompleted += new EventHandler<WService.UpdateListItemsCompletedEventArgs>(client_UpdateListItemsCompleted);
        client.UpdateListItemsAsync("Test", batch);

i found something like this:

 XmlDocument doc = new XmlDocument();
XmlElement updates = doc.CreateElement("Batch");
updates.InnerXml = string.Format(
    "<Method ID='1' Cmd='New'>" +
    "<Field Name='ID'>New</Field>" +
    "<Field Name='Title'><![CDATA[{0}]]></Field>" +
    "<Field Name='Expires'>{1}</Field>" +
    "</Method>",
    title, SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now.AddDays(15)));

XmlNode node = null;
node = service.UpdateListItems("LIST NAME", updates);

but i cant use it because in Silverlight is no XMLDocument. How can i do it with the XDocument? What is wrong and how can i fix it?

Thanks!