How to select specified node within Xpath node sets by index with Selenium?

This is a FAQ: //someName[3] means: all someName elements in the document, that are the third someName child of their parent — there may be many such elements. What you want is exactly the 3rd someName element: (//someName)[3] Explanation: the [] has a higher precedence (priority) than //. Remember always to put expressions of the … Read more

Case insensitive XPath contains() possible?

This is for XPath 1.0. If your environment supports XPath 2.0, see here. Yes. Possible, but not beautiful. /html/body//text()[ contains( translate(., ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’), ‘test’ ) ] This would work for search strings where the alphabet is known beforehand. Add any accented characters you expect to see. If you can, mark the text that interests you … Read more

how to use XPath with XDocument?

If you have XDocument it is easier to use LINQ-to-XML: var document = XDocument.Load(fileName); var name = document.Descendants(XName.Get(“Name”, @”http://demo.com/2011/demo-schema”)).First().Value; If you are sure that XPath is the only solution you need: using System.Xml.XPath; var document = XDocument.Load(fileName); var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace(“empty”, “http://demo.com/2011/demo-schema”); var name = document.XPathSelectElement(“/empty:Report/empty:ReportInfo/empty:Name”, namespaceManager).Value;

How to select following sibling/XML tag using XPath

How would I accomplish the nextsibling and is there an easier way of doing this? You may use: tr/td[@class=”name”]/following-sibling::td but I’d rather use directly: tr[td[@class=”name”] =’Brand’]/td[@class=”desc”] This assumes that: The context node, against which the XPath expression is evaluated is the parent of all tr elements — not shown in your question. Each tr element … Read more

Xml Namespace breaking my xpath!

I also have the following xPath: /List/Fields/Field When I remove the xmlns from my XML the xPath works fine. When it’s in there my xPath finds nothing If you cannot register a namespace binding and cannot use (assuming the registered prefix is “x”): /x:List/x:Fields/x:Field then there is another way: /*[name()=’List’]/*[name()=’Fields’]/*[name()=’Field’]

XPath – Selecting elements that equal a value

The XPath spec. defines the string value of an element as the concatenation (in document order) of all of its text-node descendents. This explains the “strange results”. “Better” results can be obtained using the expressions below: //*[text() = ‘qwerty’] The above selects every element in the document that has at least one text-node child with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)