我使用下面的xpath选择路径中的所有数据,一切看起来都不错,但它不会输出任何数据只有文本,并且没有错误。任何想法都错了吗? 只是文字来克服发布的限制忽略它
concat('Which Customers dealt with which branch: ', //customers/customer/cbranch[@bid]/text())
XML
<customers>
<customer cid="1">
<firstname>Sam</firstname>
<lastname>Mitchell</lastname>
<gender>Male</gender>
<dob>1991-12-12</dob>
<email>sammitch@hotmail.co.uk</email>
<address>
161, South Road, Nidrie, W79 8WG
</address>
<tel>07811119542</tel>
<cbranch bid="2" />
</customer>
<customer cid="2">
<firstname>Chris</firstname>
<lastname>Bernards</lastname>
<gender>Male</gender>
<dob>1976-04-05</dob>
<email>berny5476@gmail.com</email>
<address>
179, Park Street, Inverness, Z27 0YU
</address>
<tel>07565641232</tel>
<cbranch bid="3" />
</customer>
<customer cid="3">
<firstname>Markus</firstname>
<lastname>Imrie</lastname>
<gender>Male</gender>
<dob>1995-06-20</dob>
<email>markus117@gmail.com</email>
<address>
49, Ferry Plaza, Dunfermline, D24 1VD
</address>
<tel>07712312488</tel>
<cbranch bid="1" />
</customer>
<customer cid="4">
<firstname>Ryan</firstname>
<lastname>Murray</lastname>
<gender>Male</gender>
<dob>1995-06-23</dob>
<email>murray_ryan@hotmail.co.uk</email>
<address>
186, Skye Avenue, Inverness, K56 0MX
</address>
<tel>07508611248</tel>
<cbranch bid="6" />
</customer>
<customer cid="5">
<firstname>Alice</firstname>
<lastname>Montgomery</lastname>
<gender>Female</gender>
<dob>1985-01-01</dob>
<email>alicemont@btinternet.com</email>
<address>
158, John Road, Clydebank, P23 8DW
</address>
<tel>07560002143</tel>
<cbranch bid="8" />
</customer>
<customer cid="6">
<firstname>Daniel</firstname>
<lastname>West</lastname>
<gender>Male</gender>
<dob>1966-06-06</dob>
<email>danielwest@gmail.com</email>
<address>
94, Regent Avenue, Perth, S34 9TE
</address>
<tel>07454651321</tel>
<cbranch bid="4" />
</customer>
<customer cid="7">
<firstname>George</firstname>
<lastname>Burnett</lastname>
<gender>Male</gender>
<dob>1978-09-06</dob>
<email>gb205@hotmail.co.uk</email>
<address>
76, South Lane, Aberdeen, V28 0TF
</address>
<tel>07562537541</tel>
<cbranch bid="9" />
</customer>
<customer cid="8">
<firstname>Katie</firstname>
<lastname>Drummond</lastname>
<gender>Female</gender>
<dob>1993-11-16</dob>
<email>katiedrummond@gmail.com</email>
<address>
45, West Road, Edinburgh, A79 2EG
</address>
<tel>07654546123</tel>
<cbranch bid="5" />
</customer>
<customer cid="9">
<firstname>Lizzie</firstname>
<lastname>Alderan</lastname>
<gender>Female</gender>
<dob>1976-05-28</dob>
<email>lizziealderan@gmail.com</email>
<address>
49, Ferry Plaza, Dunfermline, D24 1VD
</address>
<tel>07651246572</tel>
<cbranch bid="7" />
</customer>
<customer cid="10">
<firstname>Rebecca</firstname>
<lastname>Almond</lastname>
<gender>Female</gender>
<dob>1997-03-30</dob>
<email>beckyalmond@gmail.com</email>
<address>
13, Harris Place, BathgateGlasgow, E74 2MR
</address>
<tel>07876123451</tel>
<cbranch bid="8" />
</customer>
</customers>
答案 0 :(得分:2)
好吧,<cbranch/>
没有text()
?你有什么期望回来?
例如,如果您想要返回@bid
2
concat('Which Customers dealt with which branch: ', /customers/customer[cbranch/@bid = '2']/email/text())
将返回
Which Customers dealt with which branch: sammitch@hotmail.co.uk