我想通过给XML源输入来创建一个组件直接使用核心服务2011年,支持SDL Tridion创建一个组件2011年如何通过提供XML源文件作为输入
我想编写代码来创建一个组件通过上传源XML。使用核心服务2011.
说XML文件的名称是helloworld.xml
和位置是D:\abcd\cdef\all\helloworld.xml
。
我已经写了这样的代码,但它不工作。
XmlDocument contentxml = new XmlDocument();
contentxml.LoadXml(@"D:\abcd\cdef\all\helloworld.xml");
Response.Write("<BR>" + contentxml.ToString());
component.Content = contentxml.ToString();
ComponentData comp = (ComponentData)client.Create(component, new ReadOptions());
Response.write
没有显示任何内容。纠正我,如果我错过了任何事情。 它没有创建任何组件,错误即将到来。
当我想这:
XmlDocument contentxml = new XmlDocument();
try
{
contentxml.LoadXml(@"D:\abcd\cdef\all\helloworld.xml");
}
catch (XmlException exp)
{
Console.WriteLine(exp.Message);
}
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
contentxml.WriteTo(xw);
Response.Write("<BR>" + sw.ToString());
component.Content = sw.ToString();
ComponentData comp = (ComponentData)client.Create(component, new ReadOptions());
这一次,它的显示unable to find UUId:
一些事情那样。
我的helloworld.xml看起来像这样。
<Content xmlns="uuid:1111eb85-0X11-11f9-1e2X-1X82X78fX920">
<first>Hello World.This is Fisrt field</first>
<second>Hello World.This is second field</second>
</Content>
如果有人分享一些示例代码来完成它,那将是非常棒的。
请说明你到目前为止所尝试过的 - 最好是不适合你的代码。就目前而言,您似乎期待人们为您编写代码。 – 2012-03-30 10:18:26
这是很难与Tridion相关的,说实话...不能够使用System.Xml类加载XML文档与CoreService或Tridion无关... – 2012-03-30 13:15:31