-1

如何在不使用核心服务在 SDL Tridion 中加载XML的情况下为组件设置内容?

4

2 回答 2

2

如果您希望通过核心服务创建常规组件,则可以避免使用此帮助程序类自己制作 XML 。

有了这个,你可以像这样创建一个组件:

schemaFields = client.ReadSchemaFields("tcm:1-2-8", true, DEFAULT_READ_OPTIONS);
component = (ComponentData)client.GetDefaultData(ItemType.Component, "tcm:1-57-2");

fields = Fields.ForContentOf(schemaFields);

component.Title = "Name of component (created at "+ DateTime.Now + ")";
fields["Title"].Value = "Title of newly created component";
fields["Intro"].Value = "Intro of newly created component";
fields["Section"].AddValue("This is the first section");
fields["Section"].AddValue("This is the section section");

component.Content = fields.ToString();

component = (ComponentData)client.Create(component, DEFAULT_READ_OPTIONS);
于 2012-05-04T14:16:56.627 回答