I am creating a C# TBB.
I have the 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 XML code “body” tag is occured multiple times. I need to extract the each and every “body” tag content. For that purpose I am using HTML agility pack. To make it work in the C# TBB, How to add the HTML agility pack DLL to the Tridion system? And also please provide a sample code snippet in html agility to loop through the body tags.
If HTML Agility is not going to work with C# TBB then please suggest me a way how to get the “body” tag content?
Thanks in advance.Early response is appreciated.
Think you can also use ILMerge to merge together your third party DLL and your TBB assembly into one single one you can then upload into Tridion.