openerp 的xpath 元素的属性值

     前些日子找了很多关于odoo的帮助文档 英文的几乎木有  中文就更不用说了这对 一个刚接触opennerp 8.0的人来说简直是种折磨.有次再做项目的时候 由于页面结构是<group></group>划分的 继承后的字段不知道怎么插入父字段视图.====小编点之烟.         

    人生有时候这是这样  永远都有那么几个暂时无法解决的烦恼.于是乎 我找到了过去的一些项目案例 做撇撇 右看看        好嘛! 汗!居然是用xpath做出来的.

 

于是在网上找了一些关于xpath的帮助文档 官方: http://www.w3.org/TR/xpath/

xpath的语法结构:

  

  • child::para selects the para element 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::name selects the name attribute of the context node

  • attribute::name:寻找name上下文节点的属性.
  • attribute::* selects all the attributes of the context node

  • attribute::*:寻找全部上下文节点的属性.
  • descendant::para selects the para element descendants(后裔) of the context node

  • descendant::para:寻找para元素的后代上下文节点
  • ancestor::div selects all div ancestors of the context node

  • 选择所有 div 上下文的祖先节点
  • ancestor-or-self::div selects the div ancestors of the context node and, if the context node is a div element, the context node as well

  • div ancestor-or-self:: 选择 div 上下文节点的祖先,如果是一个上下文节点 div 元素,上下文节点
  • descendant-or-self::para selects the para element descendants(后裔) of the context node and, if the context node is a para element, the context node as well

  • 选择 para 元素上下文节点的后代,如果上下文节点 一个 para 元素,上下文节点
  • self::para selects the context node if it is a para element, and otherwise selects nothing

  • 如果这是一个选择上下文节点 帕拉 元素,否则选择什么
  • child::chapter/descendant::para selects the para element descendants(后裔) of the chapter element children of the context node

  • para 选择 para 元素的后代 上下文节点的子元素
  • child::*/child::para selects all para grandchildren of the context node

  • 选择 所有 para 孙子的上下文节点
  • / selects the document root (which is always the parent of the document element)

  • /选择文档根( 总是文档元素的父类)
  • /descendant::para selects all the para elements in the same document as the context node

  • 选择所有的 para 同一文档中的元素上下文节点
  • /descendant::olist/child::item selects all the item elements that have an olist parent and that are in the same document as the context node

  • 选择所有的 元素有一个 olist 父母和 在同一个文档上下文节点
  • child::para[position()=1] selects the first para child of the context node

  • 选择第一个 para 上下文节点的孩子
  • child::para[position()=last()] selects the last para child of the context node

  • 选择最后一个 para上下文节点的孩子
  • child::para[position()=last()-1] selects the last but one para child of the context node

  • 选择 倒数第二个 para 上下文节点的孩子
  • child::para[position()>1] selects all the para children of the context node other than the first para child of the context node

  • 选择所有 的 para 孩子以外的其他上下文节点 第一个 para 上下文节点的孩子
  • following-sibling::chapter[position()=1] selects the next chapter sibling(兄弟姊妹) of the context node

  • 选择下一个 兄弟姐妹的上下文节点
  • preceding-sibling::chapter[position()=1] selects the previous chapter sibling of the context node

  • 选择前一个 上下文的兄弟姐妹 节点
  • /descendant(后裔)::figure[position()=42] selects the forty-second figure element in the document

  • 选择 在四十二 元素 文档
  • /child::doc/child::chapter[position()=5]/child::section[position()=2] selects the second section of the fifth chapter of the doc document element

  • 选择第二个 第五 医生 文档 元素
  • child::para[attribute::type="warning"] selects all para children of the context node that have a type attribute with value warning

  • 选择所有 帕拉 孩子的上下文节点 类型 属性和值 警告
  • child::para[attribute::type='warning'][position()=5] selects the fifth para child of the context node that has a type attribute with value warning

  • 选择第五个 帕拉 孩子的上下文节点 一个 类型 属性和值 警告
  • child::para[position()=5][attribute::type="warning"] selects the fifth para child of the context node if that child has a type attribute with value warning

  • 选择第五个 帕拉 孩子的上下文节点 有一个孩子 类型 属性和值 警告
  • child::chapter[child::title='Introduction'] selects the chapter children of the context node that have one or more title children with string-value equal to Introduction

  • 选择 孩子的上下文节点 有一个或多个 标题 的孩子 字符串值 等于 介绍
  • child::chapter[child::title] selects the chapter children of the context node that have one or more title children

  • 选择 的孩子有一个或的上下文节点 更多的 标题 孩子们
  • child::*[self::chapter or self::appendix] selects the chapter and appendix children of the context node

  • 选择 附录 的孩子 上下文节点
  • child::*[self::chapter or self::appendix][position()=last()] selects the last chapter or appendix child 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”

|“自我”

    

 

posted on 2015-05-13 14:32  象牙塔里的魔术师  阅读(200)  评论(0)    收藏  举报

导航