Xml Xpath Expression for Nested XML
我有一个 XML
1 2 3 4 5 | <font-text content-format="howdy" data-type="text"> <Index>1</Index> <Root>1</Root> <Result>302</Result> </font-text> |
如果我想取出 "Index","Root",上述 XMS 的 Xpath 表达式是什么
XPath
它已从 XSLT 3.0 移至 XPath 3.0
XPath 3.0
1 | string-join((/font-text/Result/text(), format-number(/font-text/Root/text(),'00'), format-number(/font-text/Index/text(),'00')),"-") |
XPath 2.0
1 2 3 4 | string-join((/font-text/Result/text() , substring(concat("00", /font-text/Root/text()), string-length(concat("00",/font-text/Root/text())) - 1) , substring(concat("00", /font-text/Index/text()), string-length(concat("00",/font-text/Index/text())) - 1)) ,"-") |
XPath 1.0
1 2 3 4 5 6 | concat(/font-text/Result/text() ,"-" , substring(concat("00", /font-text/Root/text()), string-length(concat("00",/font-text/Root/text())) - 1) ,"-" , substring(concat("00", /font-text/Index/text()), string-length(concat("00",/font-text/Index/text())) - 1) ) |