private string GetFaultString(XElement elem, IXPathResult result) { var fault = elem.Descendants("faultstring").FirstOrDefault(); if (fault == null) return result.GetType().Name + " did not match the expected value"; return "Aras Fault: " + fault.Value; }
private string GetFaultString(XElement elem, IXPathResult result) { var fault = elem.Descendants("faultstring").FirstOrDefault(); if (fault == null) { return(result.GetType().Name + " did not match the expected value"); } return("Aras Fault: " + fault.Value); }
public static void Main() { try { using (IEngine engine = EngineFactory.Create(new EngineOptions.Builder().Build())) { Console.WriteLine("Engine created"); using (IBrowser browser = engine.CreateBrowser()) { Console.WriteLine("Browser created"); browser.Size = new Size(1024, 768); browser.Navigation.LoadUrl("https://www.teamdev.com/dotnetbrowser").Wait(); IDocument document = browser.MainFrame.Document; string expression = "count(//div)"; Console.WriteLine($"Evaluating \'{expression}\'"); IXPathResult result = document.Evaluate(expression); // Make sure that result is a number. if (result.Type == XPathResultType.Number) { Console.WriteLine("Result: " + result.Numeric); } } } } // If the expression is not a valid XPath expression or the document // element is not available, we'll get an error. catch (XPathException e) { Console.WriteLine("Error message: " + e.Message); return; } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press any key to terminate..."); Console.ReadKey(); }