RTF Text field is Adding Namespace Tags to HTML Items
<P>This is Text</p>
and SDL is converting it into
<p xmlns="http://www.w3.org/1999/xhtml">This is Test</p>
and need help to remove following namespace tag from output.
So far i have created a TBB to replace text using
var fields = new ItemFields(cp.Content, cp.Schema);
foreach (var field in fields)
{
if (field is XhtmlField)
{
XhtmlField xhtmlField = field as XhtmlField;
xhtmlField.Value = TemplateUtilities.ResolveRichTextFieldXhtml(xhtmlField.Value);
}
}
but still output contains same Field value and need a way to replace this output.
Update: I am able to delete Namespaces using XML methods,but receiving errors during DD4T-Generate dynamic component Presentation TBB.Following TBB will remove Namespace tags from DD4T Output.
Final Solution:
Item item = package.GetByName(Package.OutputName);
if (item != null)
{
string output = item.GetAsString();
//Following regex replace xmlns strings from output.
string strXMLPattern = "\\s+xmlns\\s*(:\\w)?\\s*=\\s*\\\\\"(?<url>[^\\\"]*)\\\\\"";
var matchCol = Regex.Matches(output, strXMLPattern);
foreach (var match in matchCol)
output = output.Replace(match.ToString(), "");
package.Remove(item);
package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.String, output));
}