xpath学习中

XPath
xpath model
1. XPath
    XPath is a language for finding information in xml documents. XPath is used to navigate through elements and attributes in an xml document.
    XPath is a major element in W3C's standard XSLT.  And XQuery and XPointer are both built on XPath expressions. XQuery 1.0 and XPath 2.0 share the same data model and support the same functions.
    XPath contains a library of standard functions.

2. XPath Expressions
    XPath use path expressions to select a node or a set of nodes. these expressions are very like expressions of file system.
3. XPath standard functions.
    XPath includes over 100 built-in functions. They are functions for string values, numeric values , date and time comparison, name and QName manipulation, sequence manipulation, Boolean values, and more.

XPath terminology
 
In XPath there are several kinds of elements: nodes, attributes, text, namespace,  processing-instruction, comment and document node.

Nodes

    XML doc are treated  as tree of nodes.  The root of the tree is called the root node or document node.

XPath Syntax
    Mostly useful path expressions
    nodename      Select all child nodes of the node.
    /                        Select from the root.
    //                        Select the nodes from the documents that match the selection nomatter where they are.
    .                        Select the current node.
    ..                        Select the parent node.
    @                     Select the attributes.
 
Predicates
    Predicates are used to find a specific node or a node contains the specific value.
  XPath wildcards can be used to find unknown nodes.
    *                     Select any element nodes.
    @*                  Select any attribute nodes.
    node()            Match any node of any kind.

By using | operator XPath can select several paths.

XPath Axes
   An a
xes defines the node set relative to the current node.
    ancestor
    ancestor-or-self
    atribute
    child
    descendant
    descendant-or-self
    following
    following-sibling
    namespace
    parent
    preceding
    preceding-sibling
    self

Step
   A Step consists of
: an axis, a node-test, zero or more predicates.
    Each path expression consists of several steps separated by slash.
    parent::*
    child::book
    ancestor::lang
    attribute::lang
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值