Updating Components using the Core Service in SDL Tridion 2011

前端 未结 3 957
别跟我提以往
别跟我提以往 2020-12-17 06:58

I am updating a Component using Core Service in Tridion 2011.

The sample code is as follows,

string COMPONENT_URI = \"tcm:8-674\";
string SCHEMA_URI          


        
3条回答
  •  心在旅途
    2020-12-17 07:45

    Your code attempts to save the XML DOM to a file.

    XDocument.Save(string fileName) - Serialize this XDocument to a file, overwriting an existing file, if it exists.

    You should use something like this:

    using (var client = new SessionAwareCoreServiceClient(netTcpBinding, remoteAddress))
    {
        ReadOptions readOptions = new ReadOptions();
        ComponentData component = client.Read(compTcmUri, readOptions) as ComponentData;
        XDocument dom = XDocument.Parse(component.Content);
        // do your modifications to dom
        component.Content = dom.ToString();
        component = client.Update(component, readOptions) as ComponentData;
    
        Console.WriteLine("Component updated: " + component.LocationInfo.WebDavUrl);
    }
    

提交回复
热议问题