我正在创建一个 C# TBB。我有如下所示的 XML 代码。
<content>
<ah>123</ah>
<ph>456</ph>
<body>
<sc>hi</sc>
<value>aa</value>
<value>bb</value>
<value>cc</value>
<value>dd</value>
<value>dd</value>
</body>
<body>
<sc>hello</sc>
<value>ee</value>
<value>ddff</value>
</body>
</content>
C# 待定代码:
using (MemoryStream ms = new MemoryStream())
{
XmlTextWriter securboxXmlWriter = new XmlTextWriter(ms, new System.Text.UTF8Encoding(false));
securboxXmlWriter.Indentation = 4;
securboxXmlWriter.Formatting = Formatting.Indented;
securboxXmlWriter.WriteStartDocument();
securboxXmlWriter.WriteStartElement("component");
securboxXmlWriter.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
securboxXmlWriter.WriteAttributeString("xmlns", "http://www.w3.org/1999/xhtml");
securboxXmlWriter.WriteStartElement("content");
securboxXmlWriter.WriteStartElement("wire:wire");
securboxXmlWriter.WriteStartElement("wire:si");
securboxXmlWriter.WriteStartElement("wg:ah");
securboxXmlWriter.WriteElementString("text", package.GetValue("Component.ah"));
securboxXmlWriter.WriteEndElement();
securboxXmlWriter.WriteStartElement("wg:ph");
securboxXmlWriter.WriteElementString("nlt", package.GetValue("Component.ph"));
securboxXmlWriter.WriteEndElement();
securboxXmlWriter.WriteEndElement();
securboxXmlWriter.WriteEndElement();
securboxXmlWriter.WriteEndElement();
securboxXmlWriter.WriteEndElement();
securboxXmlWriter.WriteEndDocument();
securboxXmlWriter.Flush();
securboxXmlWriter.Close();
Item output = package.GetByName("Output");
if (output != null)
{
package.Remove(output);
}
package.PushItem("Output", package.CreateStringItem(ContentType.Xml, Encoding.UTF8.GetString(ms.ToArray())));
}
在 XML 代码中,“body”标签出现了多次。我需要提取每个“body”标签内容。为此,我正在使用 HTML 敏捷包。为了使其在 C# TBB 中工作,如何将 HTML 敏捷包 DLL 添加到 Tridion 系统?并且还请在 html 敏捷中提供一个示例代码片段以循环遍历 body 标记。
如果 HTML Agility 不能与 C# TBB 一起使用,那么请给我建议一种如何获取“body”标签内容的方法?
提前致谢。感谢您尽早回复。