How to add a third-party DLL in Tridion for C # TBB?

I am creating C # TBB. I have an XML code as shown below.

<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 # TBB Code:

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())));
}

In the body tag, XML code occurs several times. I need to extract the contents of each tag. For this I use the HTML flexibility package. To make it work in C # TBB, how do I add a dll for HTML magic to the Tridion system? Also, please give a sample code snippet in html agility to skip body tags.

If HTML Agility won't work with C # TBB, please offer me a way to get the contents of the body tag.

Thanks in advance. Higher answer is welcome.

+5
source share
3 answers

, ILMerge, DLL TBB , Tridion.

+2

DLL (GAC). .

+7

ILMerge DLL GAC. , ( ), . , : DLL- - DLL , , DLL-. DLL Tridion.

: MyTemplates, ExternalLibraryOne.dll ExternalLibraryTwo.dll. :

  • ILMerge http://www.microsoft.com/en-us/download/details.aspx?id=17630 ()
  • " " ilmerge.exe.
  • templating :

    "$ (SolutionDir) \ilmerge"
    /lib: "C:\Windows\Microsoft.NET\Framework\v4.0.30319" /t: dll/targetplatform:v4,C:\Windows\Microsoft.NET ||Framework\v4.0.30319 /out: "$(TargetDir)$(ProjectName).merged.dll" "$ (TargetDir) ExternalLibraryOne.dll" "$ (TargetDir) ExternalLibraryTwo.dll" "$ (TargetPath)"

  • . (bin/Debug bin/Release) MyTemplates.merged.dll. Tridion TcmUploadAssembly.

, .NET 4, .

+4

All Articles