Folders and files Name Name Last commit message
Last commit date
parent directory
View all files
link
installation
conda install -c conda-forge lxml
pip install lxml
如使用css:conda install -c conda-forge cssselect, pip install cssselect
usage: from lxml import etree
XPath使用路径表达式:选取xml文档中的节点或节点集
Extensible Stylesheet Language Transformations (XSLT)
XQuery, XPointer
节点类型
元素
属性
文本
命名空间
处理指令
注释
文档节点(根节点)
项目item
基本值atomic value:无父或无子的节点
节点
/AA/BB/CC: absolute path
AA/BB/CC, ./AA/BB/CC: relative path
//AA/BB/CC: start anywhere
//AA/@bb: attribute
[]: condition
[1], [last()], [last()-1]: indexing
[@aa], [@aa="233"]: attribute
[@*], [not(@*)]
misc function
[name()="233"]
[starts-with(name(), "233"]
[contains(name(),"233")]
[count(*)=2]
[string-length(name())=3]
/AA | /BB: or
::: axis, child:: is the default axis
child::
descendant::
parent::
ancestor::
numeric operations
[position() mod 2 = 0]
[position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5)]
You can’t perform that action at this time.