/*********************************************************************/ public override bool Write(HtmlToXml objParser, StringBuilder sb, int iLevel) { objParser.WriteIndentation(sb, iLevel); sb.Append(m_strText + objParser.NewLine); return(true); }
/*********************************************************************/ public override bool Write(HtmlToXml objParser, StringBuilder sb, int iLevel) { objParser.WriteIndentation(sb, iLevel); // Remove duplicate spaces and replace newlines and tabs with spaces. Encode < and > and & string strText = m_strText; // Encode < and > and & strText = strText.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Trim(); if (strText != "") { sb.Append(strText); return(true); } return(false); }
/*********************************************************************/ public override bool Write(HtmlToXml objParser, StringBuilder sb, int iLevel) { bool bEmpty = true; string strAttributes = PackAttributes(); if (strAttributes != "") { bEmpty = false; } if (m_aChildren.Count > 0) { string strBegin = ""; if (this.Name != "__") { strBegin = string.Format("<{0}{1}>" + m_objParser.NewLine, this.Name, strAttributes); } StringBuilder sbChildren = new StringBuilder(); foreach (Node objNode in this.Children) { if (m_objParser.Write(objParser, objNode, objNode.Parent, sbChildren, iLevel + 1)) { bEmpty = false; } } if (m_objParser.RemoveEmpties && bEmpty && !m_objParser.EmptiesAllowed(this)) { return(false); } if (this.Name != "__") { m_objParser.WriteIndentation(sb, iLevel); sb.Append(" " + strBegin); sb.Append(sbChildren.ToString()); m_objParser.WriteIndentation(sb, iLevel); sb.AppendFormat("</{0}> " + m_objParser.NewLine, this.Name); } else { sb.Append(" " + sbChildren.ToString() + " "); } } else { if (m_objParser.RemoveEmpties && bEmpty && !m_objParser.EmptiesAllowed(this)) { return(false); } m_objParser.WriteIndentation(sb, iLevel); sb.AppendFormat(" <{0}{1} /> " + m_objParser.NewLine, this.Name, strAttributes); } return(!bEmpty); }