openerp 的xpath 元素的属性值
前些日子找了很多关于odoo的帮助文档 英文的几乎木有 中文就更不用说了这对 一个刚接触opennerp 8.0的人来说简直是种折磨.有次再做项目的时候 由于页面结构是<group></group>划分的 继承后的字段不知道怎么插入父字段视图.====小编点之烟.
人生有时候这是这样 永远都有那么几个暂时无法解决的烦恼.于是乎 我找到了过去的一些项目案例 做撇撇 右看看 好嘛! 汗!居然是用xpath做出来的.
于是在网上找了一些关于xpath的帮助文档 官方: http://www.w3.org/TR/xpath/
xpath的语法结构:
-
child::paraselects theparaelement children of the context node - child::para:选择
para上下文节点的子元素. -
child::*selects all element children of the context node - .child::*:选择所有元素 孩子的上下文节点.
-
child::text()selects all text node children of the context node - child::text():选择所有文本上下文节点的子节点.
-
child::node()selects all the children of the context node, whatever their node type - child::node():寻找上下文节点的孩子不管是什么类型的
-
attribute::nameselects thenameattribute of the context node - attribute::name:寻找name上下文节点的属性.
-
attribute::*selects all the attributes of the context node - attribute::*:寻找全部上下文节点的属性.
-
descendant::paraselects theparaelement descendants(后裔) of the context node - descendant::para:寻找para元素的后代上下文节点
-
ancestor::divselects alldivancestors of the context node - 选择所有
div上下文的祖先节点 -
ancestor-or-self::divselects thedivancestors of the context node and, if the context node is adivelement, the context node as well div ancestor-or-self::选择div上下文节点的祖先,如果是一个上下文节点div元素,上下文节点-
descendant-or-self::paraselects theparaelement descendants(后裔) of the context node and, if the context node is aparaelement, the context node as well 选择para元素上下文节点的后代,如果上下文节点 一个para元素,上下文节点-
self::paraselects the context node if it is aparaelement, and otherwise selects nothing - 如果这是一个选择上下文节点
帕拉元素,否则选择什么 -
child::chapter/descendant::paraselects theparaelement descendants(后裔) of thechapterelement children of the context node para选择para元素的后代章上下文节点的子元素-
child::*/child::paraselects allparagrandchildren of the context node - 选择 所有
para孙子的上下文节点 -
/selects the document root (which is always the parent of the document element) - /选择文档根( 总是文档元素的父类)
-
/descendant::paraselects all theparaelements in the same document as the context node - 选择所有的
para同一文档中的元素上下文节点 -
/descendant::olist/child::itemselects all theitemelements that have anolistparent and that are in the same document as the context node - 选择所有的
项元素有一个olist父母和 在同一个文档上下文节点 -
child::para[position()=1]selects the firstparachild of the context node - 选择第一个
para上下文节点的孩子 -
child::para[position()=last()]selects the lastparachild of the context node - 选择最后一个
para上下文节点的孩子 -
child::para[position()=last()-1]selects the last but oneparachild of the context node - 选择 倒数第二个
para上下文节点的孩子 -
child::para[position()>1]selects all theparachildren of the context node other than the firstparachild of the context node - 选择所有 的
para孩子以外的其他上下文节点 第一个para上下文节点的孩子 -
following-sibling::chapter[position()=1]selects the nextchaptersibling(兄弟姊妹) of the context node 选择下一个章兄弟姐妹的上下文节点-
preceding-sibling::chapter[position()=1]selects the previouschaptersibling of the context node - 选择前一个
章上下文的兄弟姐妹 节点 -
/descendant(后裔)::figure[position()=42]selects the forty-secondfigureelement in the document 选择 在四十二图元素 文档-
/child::doc/child::chapter[position()=5]/child::section[position()=2]selects the secondsectionof the fifthchapterof thedocdocument element - 选择第二个
节第五章的医生文档 元素 -
child::para[attribute::type="warning"]selects allparachildren of the context node that have atypeattribute with valuewarning - 选择所有
帕拉孩子的上下文节点类型属性和值警告 -
child::para[attribute::type='warning'][position()=5]selects the fifthparachild of the context node that has atypeattribute with valuewarning - 选择第五个
帕拉孩子的上下文节点 一个类型属性和值警告 -
child::para[position()=5][attribute::type="warning"]selects the fifthparachild of the context node if that child has atypeattribute with valuewarning - 选择第五个
帕拉孩子的上下文节点 有一个孩子类型属性和值警告 -
child::chapter[child::title='Introduction']selects thechapterchildren of the context node that have one or moretitlechildren with string-value equal toIntroduction - 选择
章孩子的上下文节点 有一个或多个标题的孩子 字符串值 等于介绍 -
child::chapter[child::title]selects thechapterchildren of the context node that have one or moretitlechildren - 选择
章的孩子有一个或的上下文节点 更多的标题孩子们 -
child::*[self::chapter or self::appendix]selects thechapterandappendixchildren of the context node - 选择
章和附录的孩子 上下文节点 -
child::*[self::chapter or self::appendix][position()=last()]selects the lastchapterorappendixchild of the context node - 选择最后一个
章或附录上下文的孩子 节点
AxisName ::= 'ancestor'
| 'ancestor-or-self'
| 'attribute'
| 'child'
| 'descendant'
| 'descendant-or-self'
| 'following'
| 'following-sibling'
| 'namespace'
| 'parent'
| 'preceding'
| 'preceding-sibling'
| 'self'
祖先”
|“ancestor-or-self”
|“属性”
|“孩子”
|“后代”
|“子轴或self”
|“后”
|“同胞”
|“名称”
|“父”
|“前”
|“preceding-sibling”
|“自我”
浙公网安备 33010602011771号