无法使用xpath检索节点值,只能检索属性

时间:2013-06-18 18:27:33

标签: c xpath attributes

我需要用xpath(ver.1)解析这个XML。问题是我无法获取节点值,只能获取属性。 以下表达式中没有一个可用。

//name
//name/text()
/tracks/track/name

如果btw我触发

//@*

我获取所有属性值(因此xpath正在工作)。 问题是什么?我需要选择艺术家姓名,曲目名称和曲目href 请帮帮我;)

<tracks xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">
<opensearch:Query role="request" startPage="1" searchTerms="hypo fish"/>
<opensearch:totalResults>1</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>100</opensearch:itemsPerPage>
<track href="spotify:track:4YUTI6RFvt3jUX3hSbasHH">
<name>What About Fish</name>
<artist href="spotify:artist:2XtRg7z3aq8UsX1fstLJKM">
<name>Hypo</name>
</artist>
<id type="isrc">FR6V80201485</id>
<album href="spotify:album:5ZZdpcenCXZ9LlDjHT0EBb">
<name>Karaoke A Capella</name>
<released>2005</released>
<availability>
<territories>
AD AE AF AG AI AL AM AN AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IN IO IQ IR IS IT JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR ST SV SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW ZZ
</territories>
</availability>
</album>
<track-number>15</track-number>
<length>188.347000</length>
<popularity>0.04986</popularity>
</track>
</tracks>

0 个答案:

没有答案