List replies in a winform

后端 未结 1 447
轻奢々
轻奢々 2020-12-12 03:25

In my C# app I get an xml from a server that contains some replies like in a forum thread (with elements like author, time, body, title, whatever).

When I get this x

相关标签:
1条回答
  • 2020-12-12 04:15

    Yes, that's possible, you want to turn "design mode" on for the document. Add a reference to Microsoft.mshtml. Start a new Windows Forms project and drop a WB and a button on the form. Make the code look similar to this:

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            webBrowser1.DocumentText = "<html><body><textarea rows='15' cols='92' name='post-text' id='wmd-input'></textarea></body></html>";
            webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
            button1.Click += button1_Click;
        }
    
        void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
            mshtml.IHTMLDocument2 doc = webBrowser1.ActiveXInstance as mshtml.IHTMLDocument2;
            doc.designMode = "On";
        }
    
        private void button1_Click(object sender, EventArgs e) {
            var html = webBrowser1.Document.Body.All["post-text"].InnerHtml;
            // do something with that
            //...
        }
    }
    
    0 讨论(0)
提交回复
热议问题