//--- Methods --- public string Convert(XDoc html) { if (html == null || html.IsEmpty) { return(""); } var state = new VisitState(); var body = html.HasName("body") ? html : html["body[not(@target)]"]; foreach (var node in body.VisitOnly(x => IncludeNode(x, state), x => CheckBlock(x, state))) { if (CheckBlock(node, state)) { continue; } switch (node.AsXmlNode.NodeType) { case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: case XmlNodeType.CDATA: case XmlNodeType.Text: state.Append(node.AsText); break; } } return(state.ToString().Trim()); }
//--- Methods --- public string Convert(XDoc html) { if(html == null || html.IsEmpty) { return ""; } var state = new VisitState(); var body = html["body[not(@target)]"]; foreach(var node in body.VisitOnly(x => IncludeNode(x, state), x => CheckBlock(x, state))) { if(CheckBlock(node, state)) { continue; } switch(node.AsXmlNode.NodeType) { case XmlNodeType.CDATA: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Text: state.Append(node.AsText); break; } } return state.ToString(); }