예제 #1
0
        private void btn_SViewer_Click(object sender, EventArgs e)
        {
            var t = new TextViewer();

            t.colorTextBox1.Text = _html;
            t.Show();
        }
예제 #2
0
        private void btn_apply_Click(object sender, EventArgs e)
        {
            if (txt_xpath.Text.Trim() == string.Empty)
            {
                return;
            }
            try
            {
                doc.LoadHtml(_html);
                var nodes = doc.DocumentNode.SelectNodes(txt_xpath.Text);


                if (nodes == null)
                {
                    this.lbl_mutiResult.Text = "N";
                    this._output             = "";
                }
                else
                {
                    if (nodes.Count == 1)
                    {
                        this.lbl_mutiResult.Text = "S";
                    }
                    else
                    {
                        this.lbl_mutiResult.Text = "M";
                    }
                    this._output = nodes[0].OuterHtml;
                }
                OnApplied();
                var t = new TextViewer();
                t.colorTextBox1.Text = _output;
                t.Show();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
예제 #3
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            System.IO.File.WriteAllText("lastParse.txt", txt_source.Text);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("var " + xParam_Section.SelectorName + "=doc.DocumentNode.SelectNodes(\"" + xParam_Section.SelectorXPath + "\")" + xParam_Section.lbl_endFix.Text + ";");

            for (int i = 1; i < 15; i++)
            {
                var x = Controls.Find("x" + i, true)[0] as XpathParam;

                sb.AppendLine("var " + x.SelectorName + "=" + "item" + ".SelectSingleNode(\"" + x.SelectorXPath + "\")" + x.lbl_endFix.Text + ";");
            }

            TextViewer t = new TextViewer();

            t.colorTextBox1.Text = sb.ToString();
            t.ShowDialog();

            System.IO.File.WriteAllText("lastCodes.txt", sb.ToString());
        }