English 中文(简体)
帮助理解XPath
原标题:help to understand XPath
  • 时间:2010-09-28 14:59:17
  •  标签:
  • xpath

我这样说:

link[@rel= alternate  and @type= text/html  or not(@rel)]/@href | link/text()

?

确切地说,我不理解文号:

最佳回答

在XPath的管道(< >)配对。 因此,将归还连接要素(与上游相匹配)和任何链接内容的原始属性。

因此,就象碎片一样。

  <link>test</link>
  <link href="http://www.google.com">Google</link>
  <link rel="zzzz" href="http://www.stackoverflow.com">Stack Overflow</link>

页: 1

test
http://www.google.com
Google
Stack Overflow
问题回答

符号是: 它贪.了与左侧或右侧相匹配的所有因素。

x说的是:

  • Grab the href attribute of all link tags that have an attribute "rel=alternate" and an attribute "type=text/html", or grab the href of all link tags that do not have the rel attribute

gr(因工会而):

  • Grab the inner text of all link tags on the page.

祝福。

Acctually I don t understand the symbol |

www.un.org/Depts/DGACM/index_spanish.htm http://www.w3.org/TR/1999/REC-xpath-19991116/#NT-UnionExpr”rel=“nofollow” XPath Unionmente/a>。

http://www.w3.org/TR/2007/REC-xpath20-20070123/#combining_seq”rel=“nofollow”

•The union and | operators are equivalent. They take two node sequences as operands and return a sequence containing all the nodes that occur in either of the operands.

当然,只有XPath 2.0和XPath 1.0中加入“un”经营者,我们才有其早先的同义词,由>>>> 代码表示。

www.un.org/Depts/DGACM/index_spanish.htm 因此,在的特定情况下:

link[@rel= alternate  and @type= text/html  or not(@rel)]/@href | link/text()

<>XPath 以上表述选择了两套:的结合:

  1. 由以下单位选定的所有节点:link[@rel=校正和@type=text/html或(@rel)]/@href

  2. 所有节点:<代码>link/text()

工会是塞克斯岛(和数学)的一个标准业务,尽管U号是用来代表当地的工会。

www.un.org/Depts/DGACM/index_spanish.htm http://en.wikipedia.org/wiki/Union_%28set_theory%29”rel=“nofollow” Wikipedia:

The union of two sets A and B is the collection of points which are in A or in B (or in both):

www.un.org/Depts/DGACM/index_spanish.htm 简单的例子:

A = {1,2,3,4,5,6}

B = {1,5,6,7,8}


A U B = {1,2,3,4,5,6,7,8}




相关问题
VTD XML inner XPath Expressions

I have a xml file for example like this <root> <test> <bla>test1</bla> </test> <test> <bla>test2</bla> </test> <test> </test&...

C# XML adding/copying

With the following XML I am trying to copy and add to another XML but I haven t used the C# XML document objects before. So here is the XML <config> <configXML> <Connections&...

Filter SQL queries on the XML column using XPath/XQuery

I m having a table with one XML column. I d like to filter out the rows where a specific attribute in the XML match a string, essentially doing a WHERE or HAVING. The table looks something like this ...

Python XPath Result displaying only []

Hey I have just started to use Python recently and I want to use it with a bit of xPath, the thing is when I print the result of the query I only get [] and I don t know why =S import libxml2, ...