TINYXPATH (转)

来源:互联网 发布:tensorflow for java 编辑:程序博客网 时间:2024/05/16 03:34

TinyXPath examples / regression tests

Input XML tree

<a>
   <b val='123'>
      <b />
      <c />
<!-- -122.0 -->
      <d />
   </b>
<!-- 500.0 -->
   <x target='xyz'>
sub text    </x>
</a>


ExpressionResultExpected (compiled)

Results

@val123123//x/text()sub textsub text//*/comment()-122.0-122.0count(//*/comment())22sum(//@*)123123sum(//*/comment())378378true()truetruenot(false())truetruecount(//*[position()=2])22name(/*/*/*[position()=2])ccname(/*/*/*[last()])ddcount(//c/following::*)22count(/a/b/b/following::*)33count(//d/preceding::*)22name(//attribute::*)valvalcount(//b/child::*)33count(//x/ancestor-or-self::*)22count(//b/descendant-or-self::*)44count(//self::*)66count(/a/descendant::*)55count(/a/descendant::x)11count(/a/descendant::b)22count(/a/descendant::b[@val=123])11count(//c/ancestor::a)11name(//d/parent::*)bbcount(//c/ancestor::*)22name(/a/b/ancestor::*)aaname(/a/b/c/following-sibling::*)ddcount(//b/following-sibling::*)33count(//b|//a)33count(//d/preceding-sibling::*)22-3 * 4-12-12-3.1 * 4-12.4-12.412 div 52.42.43 * 72121-5.5 >= -5.5truetrue-5.5 < 3truetrue-6.0 < -7falsefalse12 < 14truetrue12 > 14falsefalse14 <= 14truetrue/a or /btruetrue/c or /bfalsefalse/a and /bfalsefalse/a and /*/btruetrue18-126618+123030count(//a|//b)33count(//*[@val])11name(//*[@val=123])bb3=4falsefalse3!=4truetrue12=12truetrue'here is a string'='here is a string'truetrue'here is a string'!='here is a string'falsefalse/a/b/@val123123count(//*/b)22name(/*/*/*[2])ccname(/*)aaname(/a)aaname(/a/b)bbname(/*/*)bbname(/a/b/c)cccount(/a/b/*)33ceiling(3.5)44concat('first ','second',' third','')first second thirdfirst second thirdceiling(5)55floor(3.5)33floor(5)55string-length('try')33concat(name(/a/b[1]/*[1]),' ',name(/a/b/*[2]))b cb ccount(/a/b/*)33count(//*)66count(//b)22contains('base','as')truetruecontains('base','x')falsefalsenot(contains('base','as'))falsefalsestarts-with('blabla','bla')truetruestarts-with('blebla','bla')falsefalsesubstring('12345',2,3)234234substring('12345',2)23452345substring('12345',2,6)23452345concat('[',normalize-space(' before and after '),']')[before and after][before and after]//*662+3+4+5141420-2-3+52020count(/a/x[1])11name(/a/*[2])xxname(/a/*[1])bbname(/a/x[1])xxcount(/a/b/c[1])11count(/a/b/c[position()=1])11count(/a/b/d[position()=3])00//*[@val]/@val123123//x[text()='sub text']/@targetxyzxyzsubstring('123.4',1)123.4123.4//**syntax errorsyntax error

Input XML tree

<xml>
   <text>
within    </text>
</xml>


ExpressionResultExpected (compiled)/xml/text/text()withinwithin

RSS feed examples

These examples show how to decode a typical XML file : the TinyXPath RSS feed

RSS version (XPath expr : /rss/@version) : 2.0
Nb of news messages (XPath expr : count(/rss/channel/item)) : 7

Xpath exprvalueconcat(/rss/channel/item[1]/pubDate/text(),' : ',/rss/channel/item[1]/title/text())Sun, 18 Jan 2004 13:33:55 GMT : TinyXPath 1.2.1 is releasedconcat(/rss/channel/item[2]/pubDate/text(),' : ',/rss/channel/item[2]/title/text())Fri, 09 Jan 2004 21:24:09 GMT : TinyXPath 1.2 is releasedconcat(/rss/channel/item[3]/pubDate/text(),' : ',/rss/channel/item[3]/title/text())Wed, 07 Jan 2004 08:52:10 GMT : Version 1.1 is outconcat(/rss/channel/item[4]/pubDate/text(),' : ',/rss/channel/item[4]/title/text())Tue, 11 Jun 2002 19:31:51 GMT : Release 0.3 is outconcat(/rss/channel/item[5]/pubDate/text(),' : ',/rss/channel/item[5]/title/text())Mon, 27 May 2002 20:14:31 GMT : Release 0.2 is outconcat(/rss/channel/item[6]/pubDate/text(),' : ',/rss/channel/item[6]/title/text())Tue, 21 May 2002 21:23:53 GMT : First release 0.1 is outconcat(/rss/channel/item[7]/pubDate/text(),' : ',/rss/channel/item[7]/title/text())Tue, 14 May 2002 20:09:56 GMT : Syntax decoding is done
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 上古卷轴5被追杀怎么办 全险车自己碰了怎么办 上古卷轴5狗死了怎么办 头发被胶粘住了怎么办 头发被口香糖粘住了怎么办 上古卷轴5杀了npc怎么办 上古卷轴5血太少了怎么办 因牙齿缺失导致变长怎么办 上古卷轴5闪退怎么办? 小米手机4卡顿怎么办 上古卷轴5任务失败怎么办 上古卷轴5爆显存怎么办 老滚5卡住了怎么办 上古卷轴5被木河镇人追杀怎么办 关门的时候有响怎么办 家里门关门太响怎么办 网上赌搏输了2万怎么办 梦见不顺心的事怎么办 振动声桥洗澡时怎么办 同校生2高潮了怎么办 经期血发黑量少怎么办 电脑键盘右边数字键不能用怎么办 御宅伴侣特别卡怎么办 电脑网络出现三角叹号怎么办 同校生2卡顿怎么办 电脑卡了没反应怎么办 促排卵泡多要怎么办 把朋友搞摔倒意外死亡怎么办 猫见到狗受惊了怎么办 头被桌子撞肿了怎么办 鱼缸里的鱼缺氧怎么办 上火眼皮打拉下来怎么办 小孩头敲了个包怎么办 四个月不吃奶怎么办啊 4个月宝宝不吃奶粉怎么办 3个月婴儿不喝奶怎么办 地图舌加裂纹舌怎么办 3个月宝宝厌食怎么办 宝宝不吃奶吃手怎么办 三个月的宝宝光吃手不吃奶怎么办 九个月宝宝积热怎么办