public void TestReturnElement() { //Arrange IXPathProcessor processor = XPathProcessorFactory.Get(XPathEngine.xpath1); //Act var result = processor.Process(DataProvider.GetInventorySample(), "//book[@id='myfave']/author"); //Assert Assert.IsNotNull(result); }
public void TestReturnString() { //Arrange IXPathProcessor processor = XPathProcessorFactory.Get(XPathEngine.xpath1); var query = "concat(//book[1]/author/first-name, ' ', //book[1]/author/last-name)"; //Act var result = processor.Process(DataProvider.GetInventorySample(), query); //Assert Assert.IsNotNull(result); Assert.AreEqual("Joe Bob", result); }
public void TestReturnBoolean() { //Arrange IXPathProcessor processor = XPathProcessorFactory.Get(XPathEngine.xpath1); var query = "//book[1]/price > 10"; //Act var result = processor.Process(DataProvider.GetInventorySample(), query); //Assert Assert.IsNotNull(result); Assert.AreEqual("True", result); }
public JsonResult ExecuteXPath(XPathDemo demo) { string result = "", error = ""; IXPathProcessor processor = XPathProcessorFactory.Get(demo.Engine); try { result = processor.Process(demo.Xml, demo.XPath); } catch (Exception e) { error = e.Message; } return(Json(new { data = result, error })); }
public void TestReturnMixed() { //Arrange IXPathProcessor processor = XPathProcessorFactory.Get(XPathEngine.xpath1); /* * Test mixed of element, attribute & text node */ var query = "//book[@id='myfave']/author/first-name"; query += " | //book[@id='myfave']/@id"; query += " | //book[@id='myfave']/author/last-name/text()"; //Act var result = processor.Process(DataProvider.GetInventorySample(), query); //Assert Assert.IsNotNull(result); }