现在的位置: 首页 > 综合 > 正文

XPath学习笔记 XPath数据模型

2012年11月11日 ⁄ 综合 ⁄ 共 1229字 ⁄ 字号 评论关闭
XPath数据模型

在XPath的视角中,elements,
attributes, text, comments, processing
instructions 甚至namespaces
都作为树结构中的互相关联的节点来表示的。某些节点如Elements,可以有子节点,有些则不可能,如attributes,根据XML规范是不能有子的。根节点则是终极的父节点。

每个节点通过不同的方式对XPath公开其属性:

  • 一个名字.某些节点如根节点,备注和文本节点的名字永远是空串"", Elements和attributes具有扩充的名字: local name 加上 namespace URI. Processing instructions 使用不受namespace处理影响的"目标"作为名字. namespace 节点则使用前缀作为名字.
  • 一个字符串值.XML源中的文本节点包含文本字符
  • A string value. Text nodes contain the text characters from the
    source XML, with line endings normalized to #xA as required by the XML specification. Text
    nodes will always contain as much text as possible, and, thus, no two
    consecutive children will ever both be text nodes and the location of CDATA
    sections is not preserved. Comment nodes
    contain the full text of the comment (minus the
    <!-- and
    --> delimiters). Attributes contain the attribute value, and processing instructions contain the text after
    the initial target and whitespace, and up to and not including the terminating
    ?>. Namespace nodes contain a URI (or the empty
    string) as a name. The root node and element
    nodes compute their string value by recursively concatenating the string values
    of all descendant nodes.

  • Children. In theory, you can ask about children
    of any node, but only the root node and element nodes will actually have
    children.

  • A position relative to all other nodes. The
    overall ordering is called the document order.

唉..累了,还是直接看英文好了.

 

抱歉!评论已关闭.