0
我解析了一些XML
數據,其中一個元素包含幾個URLs
,它們之間用逗號隔開,指向JPG
文件。我怎樣才能將字符串中的每個URL
分開並將其分配給一個變量,以便我可以提取單個圖片?我想NSScanner
會工作,因爲它掃描字符串尋找某些字符,但我不完全確定。我也讀過正則表達式也是可能的。關於我應該從哪裏開始的想法?還有其他人需要從字符串中分離URLs
嗎?另外,這裏有一個XML
文件供參考。可能使用NSScanner分隔數據
<vehicle>
<stock>T107810A</stock>
<year>2009</year>
<make>Porsche</make>
<model>Cayenne</model>
<trim>4WD</trim>
<color>Black</color>
<serial>WP1AD29PX9LA64805</serial>
<miles>38907</miles>
<cost>0</cost>
<internet>46241</internet>
<images>http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_1.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_2.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_3.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_4.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_5.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_6.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_7.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_8.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_9.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_10.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_11.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_12.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_13.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_14.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_15.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_16.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_17.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_18.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_19.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_20.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_21.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_22.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_23.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_24.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_25.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_26.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_27.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_28.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_29.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_30.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_31.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_32.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_33.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_34.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_35.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_36.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_37.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_38.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_39.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_40.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_41.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_42.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_43.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_44.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_45.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_46.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_47.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_48.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_49.jpg,http://cdn.lauc.us/photos/large/WP1AD29PX9LA64805_50.jpg</images>
<days>612</days>
</vehicle>
太棒了。謝謝@Larme –