首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >修正“read as -list:期望使用XML文档作为第一个参数的文件,在HTDP练习200中给出”itunes.xml“。

修正“read as -list:期望使用XML文档作为第一个参数的文件,在HTDP练习200中给出”itunes.xml“。
EN

Stack Overflow用户
提问于 2019-07-15 05:30:35
回答 1查看 96关注 0票数 0

我正在做HtDP练习,而我在练习200上遇到了麻烦。我照书告诉我的做了,但我一直犯同样的错误。不管我做了什么,我总能做到:

代码语言:javascript
复制
read-itunes-as-list: expects a file with XML document as first argument, given "itunes.xml"

我尝试过更改itunes.xml的名称,以及其他一些东西,但它们似乎都失败了。有人知道怎么解决这个问题吗?下面是我的代码(到目前为止):

代码语言:javascript
复制
; An LTracks is one of:
; – '()
; – (cons Track LTracks)
; Example:
;   (cons (make-track "Wild Child" "Enya" "A Day Without" 227996 2 (make-date 2002 7 17 3 55 14) 20 (make-date 2011 5 17 17 35 13))
;         '())

;(define-struct track
;  [name artist album time track# added play# played])
; A Track is a structure:
;   (make-track String String String N N Date N Date)
; interpretation An instance records in order: the track's 
; title, its producing artist, to which album it belongs, 
; its playing time in milliseconds, its position within the 
; album, the date it was added, how often it has been 
; played, and the date when it was last played
; Example:
;   (make-track "Wild Child" "Enya" "A Day Without" 227996 2 (make-date 2002 7 17 3 55 14) 20 (make-date 2011 5 17 17 35 13))

;(define-struct date [year month day hour minute second])
; A Date is a structure:
;   (make-date N N N N N N)
; interpretation An instance records six pieces of information:
; the date's year, month (between 1 and 12 inclusive), 
; day (between 1 and 31), hour (between 0 
; and 23), minute (between 0 and 59), and 
; second (also between 0 and 59).
; Example:
;   (make-date 2019 7 9 20 35 54)

; modify the following to use your chosen name
(define ITUNES-LOCATION "itunes.xml")

; LTracks
(define itunes-tracks
  (read-itunes-as-tracks ITUNES-LOCATION))

itunes.xml

代码语言:javascript
复制
<dict>
    <key>Track ID</key><integer>442</integer>
    <key>Name</key><string>Wild Child</string>
    <key>Artist</key><string>Enya</string>
    <key>Album</key><string>A Day Without</string>
    <key>Genre</key><string>New Age</string>
    <key>Kind</key><string>MPEG audio file</string>
    <key>Size</key><integer>4562044</integer>
    <key>Total Time</key><integer>227996</integer>
    <key>Track Number</key><integer>2</integer>
    <key>Track Count</key><integer>11</integer>
    <key>Year</key><integer>2000</integer>
    <key>Date Added</key><date>2002-7-17T3:55:14</date>
    <key>Play Count</key><integer>20</integer>
    <key>Play Date</key><integer>3388484113</integer>
    <key>Play Date UTC</key><date>2011-5-17T17:35:13
</dict>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-18 04:19:26

正如我在评论中提到的,您的itunes.xml格式不正确。例如,

  • 在最后一行之前的行中,您有<date>,但是没有相应的结束标记</date>
  • 日期格式是错误的。例如,2002-7-17T3:55:14应该改为2002-07-17T03:55:14

如果您从itunes.xml下载https://gist.github.com/sorawee/e92eada7d3081b308c5e9fefbcb3def3并使用它,它应该可以正常工作。

你在哪里以及如何获得你的原始itunes.xml

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57033679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档