我想从url下载xml文件。我将我的xml文件上传到谷歌硬盘并公开分享该文件。
文件内容是
<testapp><welcomePage><logoimage>mspeller</logoimage>
<titleBackgroudColor>yellow</titleBackgroudColor><aboutUsIcon>Speller</aboutUsIcon><allitemIcon>Speller</allitemIcon><welBackgroundcolor>red</welBackgroundcolor>
</welcomePage>
<user><userName>mgdan</userName><firstName>Mila</firstName><lastName>Gdan</lastName>
</user></testapp>
我正在使用网址
下载此文件 NSURL *url = [NSURL URLWithString:@"https://drive.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp=sharing"];
NSData *data = [NSData dataWithContentsOfURL:url]; // Load XML data from web
NSString *applicationDocumentsDir =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:@"config.xml"];
// write to file atomically (using temp file)
[data writeToFile:storePath atomically:TRUE];
但是下载的xml看起来像这样它从谷歌返回完整的原始数据我正在做错的
<!DOCTYPE html>
<html>
<head>
<meta content="notranslate" name="google">
<meta content="IE=edge;" http-equiv="X-UA-Compatible">
<meta content="!" name="fragment">
<title>Configuration.xml - Google Drive</title>
<style type="text/css">
#gbar,#guser{font-size:13px;padding-right:8px;padding-top:4px !important;}#gbar{padding-left:8px;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style>
<script>
_docs_flag_initialData={"jobset":"prod","docs-aiiws":"docs_warm_nf","info_params":{},"uls":"","icso":false,"docs_eoal":true,"docs_oogt":"NONE","docosEmbedApiJs":"\/\/docs.google.com\/comments\/d\/AAHRpnXsdSRJZ13fxD9ua--NCPBLpfm_dXJQy6rzoRrqyXgd3mTwXptKPl7zGQiWOqXq6aNam3ciYM4NHJ_Yrw4pg12iznl3KqA\/api\/js?hl=en_GB","docosUnreadCommentsEnabled":false,"docs-egc":true,"docs-chat_base_url":"talkgadget.google.com\/talkgadget\/","docs-chat_domain_rotation":true,"docs-ce":true,"docs-ut":2,"promo_url":"","promo_title":"","promo_title_prefix":"","promo_content_html":"","promo_element_id":"","promo_orientation":1,"promo_show_on_click":false,"promo_show_on_load":false,"show_promo":false,"docs-encp":false,"buildLabel":"texmex_2013-49-Thu_RC1","buildClNumber":"57718063","debugTask":"oa_66","docs-show_debug_info":false,"dcau":"https:\/\/chrome.google.com\/webstore\/detail\/apdfllckaahabafndbhieahigkjlhalf","ondlburl":"\/\/docs.google.com","drive_url":"\/\/drive.google.com","docs-sup":"\/file","docs-uptc":["lsrp","usp","urp","utm_source","utm_medium","utm_campaign","utm_term","utm_content"],"docs-cwsd":"","docs-al":[0,1,0,1,0]
,"docs-ndt":"Untitled Texmex","docs-eit":false,"docs-spfe":true,"docs-mriim":1800000,"docs-ecc":false,"docs-mnumea":false,"docs-ess":false,"ecbsl":true,"ecid":true,"eod":true,"docs-eilb":false,"docs-pedd":true,"docs- evr":true,"docs-eir":false,"docs-enmr":false,"docs-esrd":false,"share_ui":"jfk","server_time_ms":1387864935483,"gaia_session_id":"","enable_iframed_embed_api":true,"cup":"\/folder\/d\/{folderId}\/edit","docs-fut":"\/\/docs.google.com\/#folders\/{folderId}","esid":true,"esubid":false,"docs-etbs":true,"enable_kennedy":true,"onePickImportDocumentUrl":"","opbu":"https:\/\/docs.google.com\/picker","opru":"https:\/\/docs.google.com\/relay.html","opdu":false,"ophi":"texmex","opuci":"","docs-se":false,"docs-ebcrsct":false,"docs-iror":false,"xdbcmUri":"https:\/\/docs.google.com\/file\/xdbcm.html?pli=1","xdbcfAllowXpc":true,"docs-corsbc":false,"xdbcfAllowHostNamePrefix":true,"docs-spdy":false,"enable_client_docos":true,"enable_anchored_docos":true,"enable_docos_tickle":true,"gv_int_native":true,"enable_a11y":true,"tpc":true,"enable_pinned_revisions":false,"enable_edit_blob_revisions":false,"upload_url":"https:\/\/docs.google.com\/upload\/resumableupload","enable_toolbar":true,"enable_feedback_button":false,"enable_microscope":true,"enable_manage_timed_text":true,"video_embed_type":"PREFER_FLASH","enable_maps_embed":true,"maps_api_uri":"https:\/\/maps.googleapis.com\/maps\/api\/js?key=AIzaSyBCjpnguVjzi6vS67NdBtyYuvCYz3yBxCY&sensor=false","maps_display_uri":"https:\/\/maps.google.com\/maps","docs_abuse_link":"https:\/\/docs.google.com\/abuse?id=0B-3M5xTcGgbLYlAxR1Vqa3dRMkU","enable_csi":true,"csi_service_name":"texmex","third_party_default_icon_urls":{"icon16":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_16.png","icon32":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_32.png","icon64":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_64.png","icon128":"\/\/ssl.gstatic.com\/docs\/doclist\/images\/generic_app_icon_128.png"},"enable_chrome_webstore_link":true};
</script>
<script type="text/javascript">
(function(){(function(){function e(a){this.t={};this.tick=function(a,c,b){var d=void 0!=b?b:(new Date).getTime();this.t[a]=[d,c];if(void 0==b)try{window.console.timeStamp("CSI/"+a)}catch(e){}};this.tick("start",null,a)}var a;window.performance&&(a=window.performance.timing);var f=a?new e(a.responseStart):new e;window.jstiming={Timer:e,load:f};if(a){var c=a.navigationStart,d=a.responseStart;0<c&&d>=c&&(window.jstiming.srt=d-c)}if(a){var b=window.jstiming.load;0<c&&d>=c&&(b.tick("_wtsrt",void 0,c),b.tick("wtsrt_",
"_wtsrt",d),b.tick("tbsd_","wtsrt_"))}try{a=null,window.chrome&&window.chrome.csi&&(a=Math.floor(window.chrome.csi().pageT),b&&0<c&&(b.tick("_tbnd",void 0,window.chrome.csi().startE),b.tick("tbnd_","_tbnd",c))),null==a&&window.gtbExternal&&(a=window.gtbExternal.pageT()),null==a&&window.external&&(a=window.external.pageT,b&&0<c&&(b.tick("_tbnd",void 0,window.external.startE),b.tick("tbnd_","_tbnd",c))),a&&(window.jstiming.pt=a)}catch(g){}})();})();
</script>
<link href="/static/file/client/css/1508097430-edit_css_ltr.css" rel=
"stylesheet">
<link href=
"https://ssl.gstatic.com/docs/doclist/images/icon_11_generic_favicon.ico"
rel="shortcut icon">
<link href=
"https://chrome.google.com/webstore/detail/apdfllckaahabafndbhieahigkjlhalf"
rel="chrome-webstore-item">
<meta content="Configuration.xml">
<meta content=
"https://ssl.gstatic.com/docs/doclist/images/icon_11_generic_favicon.ico">
<meta content=
"https://docs.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp=sharing&pli=1">
</head>
<body dir="ltr" onload='_onload()'>
<noscript>
<div class="docs-butterbar-container">
<div class="docs-butterbar-wrap">
<div class=
"jfk-butterBar jfk-butterBar-shown jfk-butterBar-warning">
JavaScript isn't enabled in your browser, so this file can't be
opened. Enable and reload.
</div>
</div><br>
</div></noscript>
<div class="docs-vis-ref-chrome" id="docs-chrome" tabindex="0">
<div>
<div id="docs-header">
<div class="docs-branding-default" id=
"docs-branding-container">
<a href="//drive.google.com" target="_blank" title=
"Open Google Drive"></a>
<div id="docs-drive-logo"></div>
<div id="docs-branding-logo"></div>
</div>
<div id="gbar">
<nobr><a class="gb1" href=
"https://www.google.co.in/webhp?tab=ow" target=
"_blank">Search</a> <a class="gb1" href=
"http://www.google.co.in/imghp?hl=en-GB&tab=oi" target=
"_blank">Images</a> <a class="gb1" href=
"https://maps.google.co.in/maps?hl=en-GB&tab=ol"
target="_blank">Maps</a> <a class="gb1" href=
"https://play.google.com/?hl=en-GB&tab=o8" target=
"_blank">Play</a> <a class="gb1" href=
"https://www.youtube.com/?tab=o1" target=
"_blank">YouTube</a> <a class="gb1" href=
"https://mail.google.com/mail/?tab=om" target=
"_blank">Gmail</a> <b class="gb1">Drive</b> <a class="gb1"
href="https://www.google.com/calendar?tab=oc" target=
"_blank">Calendar</a> <a class="gb1" href=
"http://www.google.co.in/intl/en-GB/options/" style=
"text-decoration:none" target="_blank"><span style=
"text-decoration: underline">More</span> »</a></nobr>
</div>
<div id="guser">
<nobr><span class="gbi" id="gbn"></span><span class="gbf"
id="gbf"></span><span id="gbe"><a class="gb4" href=
"https://docs.google.com/abuse?id=0B-3M5xTcGgbLYlAxR1Vqa3dRMkU"
target='_blank'>Report abuse</a> |</span> <a class="gb4"
href="https://docs.google.com/settings" target=
'_blank'>Settings</a> | <a class="gb4" href=
"https://www.google.com/accounts/ServiceLogin?service=wise&passive=1209600&continue=https://docs.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp%3Dsharing%26pli%3D1&followup=https://docs.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp%3Dsharing%26pli%3D1"
id="gb_70" target="_top">Sign in</a></nobr>
</div>
<div class="gbh" style="left:0"></div>
<div class="gbh" style="right:0"></div>
<div style="clear:both"></div>
<div id="docs-titlebar-container">
<div id="docs-titlebar">
<div class="docs-title-outer">
<div class="docs-title-widget goog-inline-block"
id="docs-title-widget">
<span class="docs-title" id=
"docs-title"></span>
<div class="docs-title-inner" id=
"docs-title-inner">
<span class="docs-title" id=
"docs-title">Configuration.xml</span>
</div>
</div>
<div class="docs-star-container goog-inline-block">
<div class="goog-inline-block" id="docs-star"
style="display:none"></div>
</div>
<div class=
"docs-activity-indicator-container goog-inline-block">
</div>
</div>
</div>
<div class="docs-titlebar-buttons">
<div class="goog-inline-block docs-titlebar-button" id=
"docs-presence-container">
<div class="goog-inline-block" id="docs-presence">
</div>
<div class=
"goog-inline-block jfk-button jfk-button-standard jfk-button-narrow docs-chat jfk-button-disabled"
id="docs-chat" style="display: none">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-chat">
</div>
</div>
</div>
</div>
<div class="goog-inline-block">
<div class=
"goog-inline-block jfk-button jfk-button-standard docs-titlebar-button jfk-button-disabled"
id="docs-docos-commentsbutton">
Comments
</div>
<div id="docs-docos-caret" style="display: none">
<div class="docs-docos-caret-outer"></div>
<div class="docs-docos-caret-inner"></div>
</div>
</div><span class="goog-inline-block" id=
"docs-titlebar-share-client-button"></span>
<div class=
"goog-inline-block jfk-button jfk-button-action docs-titlebar-button jfk-button-disabled">
<span class="goog-inline-block" id=
"docs-titlebar-share-client-button"><span class=
"goog-inline-block apps-share-sprite scb-button-icon scb-unlisted-icon-white">
</span>Share</span>
</div>
</div>
</div>
</div>
<div class="docs-butterbar-container">
<div class="docs-butterbar-wrap">
<div class=
"jfk-butterBar jfk-butterBar-shown jfk-butterBar-info">
You are using an unsupported browser. Some features may
not work correctly. Upgrade to a <a class=
"docs-butterbar-link-no-pad" href=
"http://whatbrowser.org" target="_blank">modern
browser</a>, such as <a class=
"docs-butterbar-link-no-pad" href=
"https://www.google.com/chrome/?&brand=CHVN&utm_campaign=en&utm_source=en-et-na-us-docs-ug&utm_medium=et"
target="_blank">Google Chrome</a>.<a class=
"docs-butterbar-link" href="#" onclick=
"this.parentNode.parentNode.removeChild(this.parentNode);return false;">Dismiss</a>
</div>
</div><br>
</div>
</div>
<div id="docs-bars">
<div id="docs-menubars">
<div class=
"docs-menubar goog-container goog-container-horizontal" id=
"docs-menubar" tabindex="0">
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-file-menu">
File
</div>
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-edit-menu">
Edit
</div>
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-view-menu">
View
</div>
<div class=
"menu-button goog-control goog-control-disabled goog-inline-block"
id="docs-help-menu">
Help
</div>
</div>
<div class="docs-offscreen" id="docs-chat-message-a11y" style=
"height: 0; width: 0; overflow: hidden"></div>
<div id="docs-presence-menubar"></div>
</div>
<div id='docs-toolbar-wrapper'>
<div class="docs-collapsable-toolbar" id=
'docs-primary-toolbars'>
<div class="goog-toolbar" id="docs-toolbar">
<div class=
"goog-toolbar-button goog-inline-block goog-toolbar-button-disabled"
id="downloadToolbarButton">
<div class=
"goog-toolbar-button-outer-box goog-inline-block">
<div class=
"goog-toolbar-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-download">
</div>
</div>
</div>
</div>
</div>
<div class=
"goog-toolbar-button goog-inline-block goog-toolbar-button-disabled"
id="printToolbarButton">
<div class=
"goog-toolbar-button-outer-box goog-inline-block">
<div class=
"goog-toolbar-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-print">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="goog-toolbar" id="docs-side-toolbar">
<div class=
"goog-toolbar-button goog-inline-block goog-toolbar-button-disabled"
id="webstoreToolbarButton">
<div class=
"goog-toolbar-button-outer-box goog-inline-block">
<div class=
"goog-toolbar-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block">
<div class=
"docs-icon-img-container docs-icon-img docs-icon-chrome-store">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="docs-help-anchor-wrapper">
<div id="docs-help-anchor"></div>
<div id="docs-help-anchor-right"></div>
</div>
<div id="docs-additional-bars"></div>
</div>
<div class="docs-vis-ref-editor-container" id="docs-editor-container">
<div id="docs-editor" tabindex="1">
<div class="texmex-nopreview texmex-norender">
<div class="texmex-nopreview-img"><img alt=
"No preview available" src=
"https://ssl.gstatic.com/docs/doclist/images/nopreview_blank.png"></div>
<div class="texmex-nopreview-msg">
<div>
No preview available
</div><span id="texmex-nopreview-download-span" style=
"display:none"></span>
<div class=
"goog-inline-block jfk-button jfk-button-standard texmex-nopreview-download"
tabindex="0">
<span id="texmex-nopreview-download-span" style=
"display:none"></span>
</div>
</div>
</div>
<div class="texmex-desc-container" id=
"texmex-description-container" style="display: none">
<div>
<div class="texmex-text-container" id=
"texmex-text-container">
<span class=
"texmex-contents-desc-none description_text" id=
"texmex-nodescription">Enter a description</span>
</div>
</div><span class=
"texmex-description-edit-icon goog-inline-block" id=
"texmex-description-edit-icon">
</div>
</div>
</div><script src="/static/file/client/js/3569332580-edit_core__en_gb.js"
type="text/javascript"></script>
</body>
</html>
答案 0 :(得分:2)
下载网址应为https://doc-10-a4-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/87pq5ptr7ncrrd8iqnu0ep6td4f4ca8q/1387864800000/06809471879824913322/*/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU?h=16653014193614665626&e=download
https://drive.google.com/file/d/0B-3M5xTcGgbLYlAxR1Vqa3dRMkU/edit?usp=sharing
是一个网页。