void LoadCoordsGmap() { try { ManualResetEvent waitEvent = new ManualResetEvent(false); winFormsBrowserView2.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { // Wait until main document of the web page is loaded completely. if (e.IsMainFrame) { if (this.tbCoords.Text != null) { waitEvent.Set(); DOMDocument document = winFormsBrowserView2.Browser.GetDocument(); DOMInputElement searchgmap = (DOMInputElement)document.GetElementById("searchboxinput"); searchgmap.Value = tbCoords.Text; searchgmap.Click(); DOMElement searchbutton = document.GetElementById("searchbox-searchbutton"); searchbutton.Click(); } } }; } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMNode root = document.GetElementById("root"); DOMNode textNode = document.CreateTextNode("Some text"); DOMElement paragraph = document.CreateElement("p"); paragraph.AppendChild(textNode); root.AppendChild(paragraph); } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMSelectElement select = (DOMSelectElement)document.GetElementById("select-tag"); select.Value = "opel"; } }; browserView.Browser.LoadHTML("<html><body><select id='select-tag'>\n" + " <option value=\"volvo\">Volvo</option>\n" + " <option value=\"saab\">Saab</option>\n" + " <option value=\"opel\">Opel</option>\n" + " <option value=\"audi\">Audi</option>\n" + "</select></body></html>");; }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browserView.Browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView.GetComponent()); this.Controls.Add((Control)browserView.GetComponent()); DOMEventHandler domEvent = delegate(object sender, DOMEventArgs e) { DOMEventType eventType = e.Type; Console.Out.WriteLine("handleEvent = " + eventType); }; browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; documentElement.AddEventListener(DOMEventType.OnClick | DOMEventType.OnMouseDown | DOMEventType.OnMouseUp | DOMEventType.OnKeyDown, domEvent, false); } }; browserView.Browser.LoadURL("http://www.teamdev.com"); }
public Form1() { InitializeComponent(); //Change address bar by event OnClick DOMEventHandler domEvent = delegate(object sender1, DOMEventArgs e1) { DOMEventType eventType = e1.Type; }; browserView.Browser.FinishLoadingFrameEvent += delegate(object sender2, FinishLoadingEventArgs e2) { if (e2.IsMainFrame) { DOMDocument document = e2.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; documentElement.AddEventListener(DOMEventType.OnClick, domEvent, false); } try { //toolStripDebug.Text = browserView.Browser.GetDocument().GetElementByClassName("cdr_frm").GetElementByTagName("input").GetAttribute("value").ToString(); toolStripAddress.Text = browserView.Browser.URL.ToString(); this.Text = browserView.Browser.Title; } catch { } }; }
public WindowMain() { BrowserContext browserContext = BrowserContext.DefaultContext; Browser browser = BrowserFactory.Create(browserContext); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = browser.GetDocument(); XPathResult result = document.Evaluate("count(//div)"); // If the expression is not a valid XPath expression or the document // element is not available, we'll get an error. if (result.IsError) { Console.WriteLine("Error: " + result.ErrorMessage); return; } // Make sure that result is a number. if (result.IsNumber) { Console.WriteLine("Result: " + result.Number); } } }; browserView = new WPFBrowserView(browser); Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browserView.Browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView.GetComponent()); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { Browser myBrowser = e.Browser; DOMDocument document = myBrowser.GetDocument(); DOMElement link = document.GetElementById("button"); if (link != null) { link.Click(); } } }; browserView.Browser.LoadHTML("<html><body><button id='button' " + "onclick=\"alert('Button has been clicked!');\">Click Me!</button>" + "</body></html>"); }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; // Get the div with id = "root". DOMNode divRoot = documentElement.QuerySelector("#root"); // Get all paragraphs. List <DOMNode> paragraphs = divRoot.QuerySelectorAll("p"); foreach (var paragraph in paragraphs) { Console.Out.WriteLine("paragraph.NodeValue = " + ((DOMElement)paragraph).InnerText); } waitEvent.Set(); } }; browser.LoadHTML( "<html><body><div id='root'>" + "<p>paragraph1</p>" + "<p>paragraph2</p>" + "<p>paragraph3</p>" + "</div></body></html>"); waitEvent.WaitOne(); } }
public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMInputElement firstName = (DOMInputElement)document.GetElementByName("firstName"); DOMInputElement lastName = (DOMInputElement)document.GetElementByName("lastName"); DOMInputElement agreement = (DOMInputElement)document.GetElementByName("agreement"); firstName.Value = "John"; lastName.Value = "Doe"; agreement.Checked = true; } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement link3Element = document.GetElementById("link3"); DOMEventHandler link3Event = delegate(object domEventSender, DOMEventArgs domEventArgs) { if (domEventArgs.Type == DOMEventType.OnFocus) { Console.Out.WriteLine("link3 gets focus"); } if (domEventArgs.Type == DOMEventType.OnBlur) { Console.Out.WriteLine("Remove focus from link3"); } }; link3Element.AddEventListener(DOMEventType.OnFocus | DOMEventType.OnBlur, link3Event, false); DOMElement elementFocused = null; foreach (DOMElement element in document.GetElementsByTagName("a")) { Thread.Sleep(2000); element.Focus(); elementFocused = element; } if (elementFocused != null) { Thread.Sleep(2000); elementFocused.Blur(); } } }; browserView.Browser.LoadHTML(@"<html> <body> <a id='link1' href='#'>The link 1</a> <a id='link2' href='#'>The link 2</a> <a id='link3' href='#'>The link 3</a> <script type='text/javascript'> var link2 = document.getElementById('link2'); link2.addEventListener('focus', function () { console.log('link2 gets focus'); }); link2.addEventListener('blur', function () { console.log('Remove focus from link2'); }); </script> </body> </html>"); }
public void IntentarSubirVideos_Tick(object sender, EventArgs e) { TiempoDeSubir++; progressBar1.Maximum = 60 * 30; try { progressBar1.Value = TiempoDeSubir; } catch { } if (TiempoDeSubir > 60 * 30 && descasar >= 24) { descasar++; TiempoDeSubir = 0; } if (descasar >= 48) { descasar = 0; } if (TiempoDeSubir > 60 * 30 && descasar < 24) { if (VideosNuevos() > -1) { descasar++; TiempoDeSubir = 0; string CanalDondeSubir = Directory.GetParent(DirDeVideosDeVideos[0]).Name; string URLdelCanalDondeSubir = canales.FirstOrDefault(xt => xt.Nombre.Contains(CanalDondeSubir)).URL; waitEvent.Reset(); BrowserView.Browser.LoadURL(URLdelCanalDondeSubir); dialogHandler.DireccionDeVideo = DirDeVideosDeVideos[0]; BrowserView.Browser.DialogHandler = dialogHandler; waitEvent.WaitOne(); Thread.Sleep(3000); DOMDocument document = BrowserView.Browser.GetDocument(); DOMNode div = document.GetElementById("start-upload-button-single"); DOMElement input = div.GetElementByTagName("button"); //Coordinates of the input element int x = input.BoundingClientRect.X; int y = input.BoundingClientRect.Y; //Modify to click on element. Otherwise - beside x += 1; y += 1; BeginInvoke(new Action(() => { BrowserView.InputSimulator.SimulateMouseButtonEvent(MouseButton.Left, MouseButtonState.Pressed, 1, x, y); //Simulate the button click Thread.Sleep(50); BrowserView.InputSimulator.SimulateMouseButtonEvent(MouseButton.Left, MouseButtonState.Released, 1, x, y); })); Thread.Sleep(25000); Directory.Delete(DirDeVideosDeVideos[0]); canales.Remove(canales.FirstOrDefault(xt => xt.Nombre.Contains(CanalDondeSubir))); } } }
/// <summary> /// 在本地保存Xml文件 /// </summary> /// <param name="doc"></param> /// <param name="Aroottag"></param> /// <param name="Aysdh"></param> private void SaveLocalXml(DOMDocument doc, string Aroottag, string Aysdh) { try { IXMLDOMElement rootnode = doc.documentElement; IXMLDOMNode modelNode = rootnode.selectNodes(Aroottag + "/bill_body/item")[0].cloneNode(true); IXMLDOMNode NewNode; IXMLDOMNode NewSubNode; IXMLDOMNode Parentnode; IXMLDOMNode body = rootnode.selectSingleNode(Aroottag + "/bill_body"); for (int i = 0; i < body.childNodes.length; i++) { body.removeChild(body.childNodes[i]); } DataSet ds = PDParam.GetXmldata(Aysdh); if (ds != null) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Parentnode = rootnode.selectSingleNode(Aroottag + "/bill_body"); if (i > 0) { modelNode = rootnode.selectNodes(Aroottag + "/bill_body/item")[0].cloneNode(true); } NewNode = Parentnode.appendChild(modelNode); NewSubNode = NewNode.selectSingleNode("cinventorycode"); NewSubNode.text = ds.Tables[0].Rows[i]["wlh"].ToString(); NewSubNode = NewNode.selectSingleNode("vbatchcode"); NewSubNode.text = ds.Tables[0].Rows[i]["pch"].ToString(); NewSubNode = NewNode.selectSingleNode("vfree1"); NewSubNode.text = ds.Tables[0].Rows[i]["sx"].ToString(); NewSubNode = NewNode.selectSingleNode("naccountastnum"); NewSubNode.text = ds.Tables[0].Rows[i]["sumzcsl"].ToString(); NewSubNode = NewNode.selectSingleNode("naccountnum"); NewSubNode.text = ds.Tables[0].Rows[i]["sumzczl"].ToString(); NewSubNode = NewNode.selectSingleNode("ncheckastnum"); NewSubNode.text = ds.Tables[0].Rows[i]["sumspsl"].ToString(); NewSubNode = NewNode.selectSingleNode("nchecknum"); NewSubNode.text = ds.Tables[0].Rows[i]["sumspzl"].ToString(); } string apppathxml = "../../webinfo/xml"; string pathName = Server.MapPath(apppathxml); if (!Directory.Exists(pathName)) { Directory.CreateDirectory(pathName); } string filename = "Wms-" + Aysdh + ".xml"; doc.save(pathName + "/" + filename); } } catch { this.PrintfError("本地保存Xml文件时出现错误,请重试"); return; } }
protected void btnHandLoad_Click(object sender, ImageClickEventArgs e) { try { int rowIndex = Convert.ToInt32(this.hidRowIndex.Value); string[] fileNames = this.grdLog.Rows[rowIndex].Cells[6].Text.Split('\\'); string fileName = fileNames[fileNames.Length - 1]; string path = "../../Logerror/" + DateTime.Now.ToShortDateString();; if (!Directory.Exists(Server.MapPath(path))) { Directory.CreateDirectory(Server.MapPath(path)); } XmlDocument doc = new XmlDocument(); doc.Load("http://" + Common.INTERFACESERVER + "/acctruewms/" + fileName); doc.Save(Server.MapPath(path) + "/" + fileName);//保存本地文件 MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTPClass(); xmlhttp.open("post", Common.NCWERBSERVER, false, "", ""); DOMDocument sDoc = new DOMDocument(); sDoc.loadXML(doc.InnerXml); xmlhttp.send(sDoc); if (xmlhttp.status == 200) { string comResult = ""; string comDes = ""; doc.LoadXml(xmlhttp.responseText); XmlElement rootRoot = doc.DocumentElement; string rootTag = rootRoot.GetAttribute("roottag"); XmlNode node = rootRoot.SelectSingleNode(rootTag + "/resultcode"); if (node != null) { comResult = node.InnerText.Trim(); } XmlNode nodeDes = rootRoot.SelectSingleNode(rootTag + "/resultdescription"); if (nodeDes != null) { comDes = nodeDes.InnerText.Trim(); } HtmlInputHidden hidCom = (HtmlInputHidden)this.grdLog.Rows[rowIndex].Cells[0].FindControl("hidComid"); string comID = hidCom.Value; int uResult = DataOperClass.ReLoadLog(comResult, comDes, comID); if (uResult == -1) { PrintfError("数据访问失败!"); return; } BindGridView(); PrintfError("手工加载成功"); } } catch { this.PrintfError("数据访问错误!"); return; } }
public static __XDocument Parse(string text) { var doc = new DOMDocument(); doc.loadXML(text); return(new __XDocument { InternalDocument = doc }); }
public void InternalEnsureValue() { if (this.InternalValue == null) { var doc = new DOMDocument(); var item = doc.createElement(this.InternalElementName.LocalName); doc.appendChild(item); this.InternalValue = doc.documentElement; } }
private void Browser_FinishLoadingFrameEvent(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame && e.ValidatedURL.Contains("loginURL")) { DOMDocument document = e.Browser.GetDocument(); DOMInputElement username = (DOMInputElement)document.GetElementById("id_Username"); DOMInputElement password = (DOMInputElement)document.GetElementById("id_Password"); username.Value = "fo2"; password.Value = "f2342156f"; e.Browser.FinishLoadingFrameEvent -= Browser_FinishLoadingFrameEvent; } }
public void Check(int idSolicitud, Eventos evento, string xmlContent) { if (idSolicitud == _idSolicitud) { prevXmlData = xmlData; xmlData = xmlContent; DOMDocument Xml = new DOMDocument(); Xml.loadXML(xmlData); root = Xml.documentElement; Ejecutar(T(Estado_Actual, evento)); } }
private void btnSelectedHtml_Click(object sender, RoutedEventArgs e) { label.Content = "Frames count: " + browserView.Browser.GetFramesIds().Count; DOMDocument document = browserView.Browser.GetDocument(); int i = 0; foreach (long frameId in browserView.Browser.GetFramesIds()) { DOMDocument frameDocument = browserView.Browser.GetDocument(frameId); i++; textBlock.Text += "\n\n" + "Frame #" + i + '\n' + frameDocument.DocumentElement.InnerHTML; } }
private void on_expr_activate(object o, EventArgs args) { string ex = expr_entry.Text; DOMDocument doc = webview.DomDocument; Console.WriteLine(doc); DOMNodeList nodes = doc.GetElementsByTagName("a"); ulong l = nodes.Length; for (ulong i = 0; i < l; i++) { DOMHTMLAnchorElement a = nodes.Item(i) as DOMHTMLAnchorElement; Console.WriteLine("Node {0}", a.Href); } }
protected override void EnviarNotifDeAprobacion() { _statusDoc = (int)Estatus.REVISADO; //_Observacion = _index + 1 < _ruta.Length ? root.childNodes[3].text : string.Empty; _Observacion = string.Empty; bool _fecha = _index + 1 < _ruta.Length ? true : false; DOMDocument Xml = new DOMDocument(); Xml.loadXML(prevXmlData); IXMLDOMElement _root = Xml.documentElement; if (_index < _ruta.Length) { _staff_from = int.Parse(_root.childNodes[2].text); DataSet ds = SqlHelper.ExecuteDataset(WinflowAC.ConnectionString.FormarStringConexion(), Queries.WF_BuscarEmpleadoEspecifico, _staff_from); _email_from = ds.Tables[0].Rows[0]["emp_str_email"].ToString(); } //string Mensaje = ConstruirMensaje(_idWorkflow,_Referencia,ENVIAR_NOTIF_DE_APROBACION,out _email_title, out _email_from_sys); //EmailHelper.SendEmail(ConfigurationSettings.AppSettings[WinflowAC.Global.CfgKeySmtpServer],_email_origen,_email_from_sys,_email_title,Mensaje,System.Web.Mail.MailFormat.Html); //===================================================== // NUEVO FORMA //===================================================== string Mensaje = ""; DataSet dstSolicitud = SqlHelper.ExecuteDataset(WinflowAC.ConnectionString.FormarStringConexion(), Queries.WF_CargarDatosSolicitud, _idWorkflow, _Referencia); if (Convert.ToInt16(dstSolicitud.Tables[0].Rows[0]["posicion"]) == Convert.ToInt16(dstSolicitud.Tables[0].Rows[0]["num_aprob"])) // SI ES LA PROBACION FINAL { Mensaje = ConstruirMensajeAprobacion(_idWorkflow, _Referencia, ENVIAR_NOTIF_DE_APROBACION, out _email_title, out _email_from_sys); } else { Mensaje = ConstruirMensaje(_idWorkflow, _Referencia, ENVIAR_NOTIF_DE_APROBACION, out _email_title, out _email_from_sys); } EmailHelper.SendEmail(ConfigurationSettings.AppSettings[WinflowAC.Global.CfgKeySmtpServer], _email_origen, _email_from_sys, _email_title, Mensaje, System.Web.Mail.MailFormat.Html); dstSolicitud = null; //===================================================== //===================================================== _index++; // Se sale de este estado con un evento automático [Neutro] GuardarHistorico(_idSolicitud, _statusDoc, ENVIAR_NOTIF_DE_APROBACION, _Observacion, _index, _staff_from, _staff_to, prevXmlData, xmlData, _fecha); }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { // Wait until main document of the web page is loaded completely. if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); List <DOMNode> divs = document.GetElementsByTagName("div"); foreach (DOMNode div in divs) { if (div.NodeType == DOMNodeType.ElementNode) { DOMElement divElement = (DOMElement)div; Console.Out.WriteLine(@"class = {0}; offsetTop = {1}; offsetLeft = {2}; offsetWidth = {3}; offsetHeight = {4} ; clientTop = {5}; clientLeft = {6}; clientWidth = {7}; clientHeight = {8} ; scrollTop = {9}; scrollLeft = {10}; scrollWidth = {11}; scrollHeight = {12}" , divElement.GetAttribute("class") , divElement.OffsetTop , divElement.OffsetLeft , divElement.OffsetWidth , divElement.OffsetHeight , divElement.ClientTop , divElement.ClientLeft , divElement.ClientWidth , divElement.ClientHeight , divElement.ScrollTop , divElement.ScrollLeft , divElement.ScrollWidth , divElement.ScrollHeight ); } } waitEvent.Set(); } }; browser.LoadURL("http://www.google.com"); waitEvent.WaitOne(); Thread.Sleep(100000); } }
public IXMLDOMNode AddChildFromNode(IXMLDOMNode newNode, IXMLDOMNode Parent) { try { IXMLDOMElement xnod = _root.createElement(newNode.nodeName); DOMDocument doc = new DOMDocument(); doc.loadXML(newNode.xml); IXMLDOMNode xnodReturn = Parent.appendChild(doc.documentElement); return(xnodReturn); } catch { throw; } return(null); }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement button = document.GetElementById("button-id"); button.Children[0].NodeValue = "New Button Name"; } }; browserView.Browser.LoadHTML("<html><body><button id='button-id'>Button</button></body></html>"); }
public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); var myEvent = browser.CreateEvent("MyEvent"); DOMNode root = document.GetElementById("root"); DOMEventHandler domEvent = delegate(object s, DOMEventArgs evt) { if (evt.EventType == myEvent.EventType) { DOMNode textNode = document.CreateTextNode("Some text"); DOMElement paragraph = document.CreateElement("p"); paragraph.AppendChild(textNode); root.AppendChild(paragraph); } }; root.AddEventListener(myEvent, domEvent, false); Thread.Sleep(3000); root.DispatchEvent(myEvent); } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
/// <summary> /// This method has to use the old XSL Processor because of the fact that the /// http://www.w3.org/TR/WD-xsl namespace is unsupported. /// /// The simplest way was to use the old xsl instead of re-inventing the wheel. /// I could not find a way to easily fully convert this to XSLT 1.0 due to /// the lack of namespace and cdata 'selectability'. /// /// This brings back memories :) /// </summary> /// <param name="xmlToRender">the xml string to render</param> /// <returns>HTML string</returns> internal static string Render(string xmlToRender) { XSLTemplate oXSLT; FreeThreadedDOMDocument oStyleSheet; IXSLProcessor oXSLTProc; DOMDocument oXMLSource; try { oXSLT = new XSLTemplate(); oStyleSheet = new FreeThreadedDOMDocument(); oXMLSource = new DOMDocument(); oStyleSheet.async = false; oStyleSheet.loadXML(XmlRender.XMLToHTML); oXSLT.stylesheet = oStyleSheet; oXSLTProc = oXSLT.createProcessor(); oXMLSource.async = false; oXMLSource.loadXML(xmlToRender); oXSLTProc.input = oXMLSource; oXSLTProc.transform(); return oXSLTProc.output.ToString(); } catch (Exception e) { return e.Message; } finally { oXSLT = null; oStyleSheet = null; oXMLSource = null; oXSLTProc = null; } }
/// <summary> /// This method has to use the old XSL Processor because of the fact that the /// http://www.w3.org/TR/WD-xsl namespace is unsupported. /// /// The simplest way was to use the old xsl instead of re-inventing the wheel. /// I could not find a way to easily fully convert this to XSLT 1.0 due to /// the lack of namespace and cdata 'selectability'. /// /// This brings back memories :) /// </summary> /// <param name="xmlToRender">the xml string to render</param> /// <returns>HTML string</returns> internal static string Render(string xmlToRender) { XSLTemplate oXSLT; FreeThreadedDOMDocument oStyleSheet; IXSLProcessor oXSLTProc; DOMDocument oXMLSource; try { oXSLT = new XSLTemplate(); oStyleSheet = new FreeThreadedDOMDocument(); oXMLSource = new DOMDocument(); oStyleSheet.async = false; oStyleSheet.loadXML(XmlRender.XMLToHTML); oXSLT.stylesheet = oStyleSheet; oXSLTProc = oXSLT.createProcessor(); oXMLSource.async = false; oXMLSource.loadXML(xmlToRender); oXSLTProc.input = oXMLSource; oXSLTProc.transform(); return(oXSLTProc.output.ToString()); } catch (Exception e) { return(e.Message); } finally { oXSLT = null; oStyleSheet = null; oXMLSource = null; oXSLTProc = null; } }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement link = document.GetElementById("link"); Dictionary <String, String> attributes = link.Attributes; foreach (var attribute in attributes) { Console.Out.WriteLine(attribute.Key + " = " + attribute.Value); } waitEvent.Set(); } }; browser.LoadHTML("<html><body><a href='#' id='link' title='link title'></a></body></html>"); waitEvent.WaitOne(); } }
void LoadClomplete() { var x = 458; var y = 203; var clickCount = 1; BrowserView.InputSimulator.SimulateMouseButtonEvent(MouseButtons.Left, System.Windows.Input.MouseButtonState.Pressed, clickCount, x, y); BrowserView.InputSimulator.SimulateMouseButtonEvent(MouseButtons.Left, System.Windows.Input.MouseButtonState.Released, clickCount, x, y); Thread.Sleep(5000); DOMDocument document = BrowserView.Browser.GetDocument(); List <DOMNode> divs = document.GetElementsByTagName("input"); foreach (DOMNode div in divs) { if (div.NodeType == DOMNodeType.ElementNode) { DOMElement divElement = (DOMElement)div; if (divElement.GetAttribute("class").Contains("yt-uix-form-input-text video-settings-title")) { divElement.SetInnerText("Titulo"); } } } }
public static string BuildMessage(string formatFile, params object[] parameterValues) { if (parameterValues == null) { return(null); } string xmlContent = "<root>"; for (int i = 0; i < parameterValues.Length; i++) { xmlContent += "<param" + i + ">" + parameterValues[i].ToString().Trim() + "</param" + i + ">"; } xmlContent += "</root>"; DOMDocument xslDoc = new DOMDocument(); DOMDocument xmlDoc = new DOMDocument(); xmlDoc.loadXML(xmlContent); xslDoc.load(formatFile); return(xmlDoc.transformNode(xslDoc)); }
public static extern jQuery.Elements jQuery(DOMDocument document);
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { lock (msgQueue) { try { msg = msgQueue.Receive(new TimeSpan(0, 0, 3)); msg.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(objMensaje), typeof(Eventos) }); objM = (objMensaje)msg.Body; DOMDocument Xml = new DOMDocument(); bool exitoso = Xml.loadXML(objM._Input); if (exitoso) { IXMLDOMElement root = Xml.documentElement; // primer parámetro : cod_workflow - segundo parámetro : str_referencia DataSet ds = SqlHelper.ExecuteDataset(WinflowAC.ConnectionString.FormarStringConexion(), Queries.WF_ConsultarSolicitud, int.Parse(root.childNodes[0].text), root.childNodes[1].text); int nRows = ds.Tables[0].Rows.Count; int intCodCreador = 0; //+ Nuevo int intNumPosAct = 0; int intCodWF = 0; string strNumRef = string.Empty; string strDescRuta = string.Empty; int intEstatusWF = 0; int intEstatusDoc = 0; string strPrevXml = string.Empty; string strXml = string.Empty; int intCodEmpDesde = 0; int intCodEmpHasta = 0; bool blnActual = false; int intIndexActual = 0; //+ string strPrev = string.Empty; if (objM._Evento == Eventos.CREAR_SOLICITUD && nRows == 0) { CreateStateMachine(int.Parse(root.childNodes[0].text), root.childNodes[1].text, int.Parse(root.childNodes[2].text), root.childNodes[4].text); } else { SolicitudActual = Convert.ToInt32(ds.Tables[0].Rows[0]["swf_cod_solicitud"]); try { intCodCreador = Convert.ToInt32(ds.Tables[0].Rows[0]["hwf_cod_empleado_origen"]); strPrev = Convert.ToString(ds.Tables[0].Rows[0]["hwf_str_prevxmldata"]); } catch (Exception ee) { intCodCreador = 0; strPrev = string.Empty; System.Console.Write(ee.Message); } } IEnumerator arrayList = array.GetEnumerator(); if (objM._Evento == Eventos.CAMBIO_DE_DESTINATARIO) { //* Antes /* * bool blnActualCD=false; * int intIndexActualCD=0; * while ( arrayList.MoveNext() ) * { * blnActualCD=((StateMachine)arrayList.Current).Check(SolicitudActual); * intIndexActualCD++; * if(blnActualCD) * break; * * } */ //* ((StateProcSmpl)arrayList.Current).ActualizarAprobador(int.Parse(root.childNodes[2].text), SolicitudActual); ((StateMachine)arrayList.Current).Check(SolicitudActual, objM._Evento, objM._Input); // array.RemoveAt(intIndexActual-1); // StateMachine sMach = new StateProcSmpl(SolicitudActual,int.Parse(root.childNodes[0].text),root.childNodes[1].text,StateConst.ESPERAR_CORRECCION,root.childNodes[4].text,1,intCodCreador,strPrev); // array.Add(sMach); // sMach.Check(SolicitudActual,objM._Evento,objM._Input); } else { if (objM._Evento == Eventos.SOLICITUD_CORREGIDA) { blnActual = false; intIndexActual = 0; while (arrayList.MoveNext()) { blnActual = ((StateMachine)arrayList.Current).Check(SolicitudActual); intIndexActual++; if (blnActual) { break; } } array.RemoveAt(intIndexActual - 1); StateMachine sMach = new StateProcSmpl(SolicitudActual, int.Parse(root.childNodes[0].text), root.childNodes[1].text, StateConst.ESPERAR_CORRECCION, root.childNodes[4].text, 1, intCodCreador, strPrev); array.Add(sMach); // *Anterior //sMach.Check(SolicitudActual,objM._Evento,objM._Input); } // +Nuevo if ((objM._Evento == Eventos.SOLICITUD_APROBADA) || (objM._Evento == Eventos.RECHAZADO_PARCIAL) || (objM._Evento == Eventos.RECHAZADO_TOTAL)) { //+ Nuevo intNumPosAct = Convert.ToInt32(ds.Tables[0].Rows[0]["swf_num_posicion_actual"]); intCodWF = Convert.ToInt32(ds.Tables[0].Rows[0]["swf_cod_workflow"]); strNumRef = Convert.ToString(ds.Tables[0].Rows[0]["swf_str_referencia"]); strDescRuta = Convert.ToString(ds.Tables[0].Rows[0]["swf_desc_ruta"]); intEstatusWF = Convert.ToInt32(ds.Tables[0].Rows[0]["hwf_cod_estatuswkf"]); intEstatusDoc = Convert.ToInt32(ds.Tables[0].Rows[0]["hwf_cod_estatusdoc"]); strPrevXml = Convert.ToString(ds.Tables[0].Rows[0]["hwf_str_prevxmldata"]); strXml = Convert.ToString(ds.Tables[0].Rows[0]["hwf_str_xmldata"]); intCodEmpDesde = Convert.ToInt32(ds.Tables[0].Rows[0]["hwf_cod_empleado_origen"]); intCodEmpHasta = Convert.ToInt32(ds.Tables[0].Rows[0]["hwf_cod_empleado_destino"]); intCodCreador = Convert.ToInt32(ds.Tables[0].Rows[0]["swf_cod_empleado_creador"]); //+ blnActual = false; intIndexActual = 0; while (arrayList.MoveNext()) { blnActual = ((StateMachine)arrayList.Current).Check(SolicitudActual); intIndexActual++; if (blnActual) { break; } } if (blnActual) { array.RemoveAt(intIndexActual - 1); } StateMachine sMach = new StateProcSmpl((int)SolicitudActual, intCodWF, strNumRef, intEstatusWF, intEstatusDoc, strDescRuta, intNumPosAct, strPrevXml, strXml, intCodCreador, intCodEmpDesde, intCodEmpHasta); array.Add(sMach); } // + //*else //*{ arrayList = array.GetEnumerator(); while (arrayList.MoveNext()) { ((StateMachine)arrayList.Current).Check(SolicitudActual, objM._Evento, objM._Input); } //*} } } } catch { //arrayList = array.GetEnumerator(); EstadoActual = StateConst.INICIO; //while ( arrayList.MoveNext() ) //{ // ((StateMachine)arrayList.Current).Check(); // EstadoActual = ((StateMachine)arrayList.Current).EstadoActual; // if(EstadoActual == StateConst.FIN) // { // array.Remove(arrayList.Current); // } //} int i = 0, count = array.Count; while (i < count) { ((StateMachine)array[i]).Check(); EstadoActual = ((StateMachine)array[i]).EstadoActual; if (EstadoActual == StateConst.FIN) { array.RemoveAt(i); count--; } else { i++; } } arrayList = array.GetEnumerator(); } // end catch } }
public static jQuery JQuery(DOMDocument document) { return(new jQuery(document)); }
public NetUserInfo() { //initialize Object //Get net info const string apiUrl = "http://ipinfodb.com/ip_query.php"; var httpClient = new WebClient(); try { string response = httpClient.DownloadString(apiUrl); var xmlResponse = new DOMDocument(); xmlResponse.loadXML(response); const string r = " "; _xmlContent = xmlResponse.text.Split(r.ToCharArray()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static extern jQuery.Elements jQuery(string html, DOMDocument ownerDocument);