markdown XPath几点提示

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown XPath几点提示相关的知识,希望对你有一定的参考价值。

#### in this case after `<some-component>` html element is lot of tags inbetween.  We skip them by `//li` and search only `<li>` that has a given string `//some-component//li`. For some tags (`span`, `a`, `button`) has direct `text()` working but for `<li>` `text()` returns `undefined`. Two solutions in b) and c)
a) `//some-component/li/span[text() = "' + name + '"];`

b) `//some-component/li[text()[contains(.,"'+ name +'")]];`

c) `//some-component/li[contains(., "'+ name +'")];`

#### if there is more nesting below `<li>` to get text from last `<li>` element we can use:
`//some-component//li[text()[contains(text(), "' + name '")]];`

#### remove unnecesary space in `span`, `a` text element
`//td[@class='score-time status']/a[normalize-space() = '16 : 00']`

#### other search by input value
`//button[@value='press me']`

#### other search by class name
`//div[contains(@class, "' + name + '")];`

#### find parent of element
a) `//div/span[contains(text(), 'XYZ')]/..  //div`

b) `//div/span/li/a/ancestor::div`  //more specific

#### find by comments in html with string
`//ul/li/comment()[contains(., 'item in $select.items')]`

#### get div with attribute
`//div/@some-attribute-name` //cannot select more elements after this selection

`//div[@some-attribute-name="value"]//h3/span`

#### select next `div` sibling
`//div[text() = ' Color Digest ']/following-sibling::div`

#### select given element from list
`//ol[contains(@id, "autocomplete-view")][1]` - usually works but if cannot find another than first element use:

`(//ol[contains(@id, "autocomplete-view")])[1]`

以上是关于markdown XPath几点提示的主要内容,如果未能解决你的问题,请参考以下文章

markdown 一份报告显示了eXist实现XPath&XQuery函数和运算符规范中的函数签名不匹配

XML——XPATH语法介绍

通过 XPATH 选择 <a href> HTML 标记的文本部分

Eclipse几点常用设置+个人喜好

C#提升性能的几点提示和技巧

关于表单设计(登录)的几点感悟