透過JS跨網域存取XML檔
為了一些安全性的因素,通常伺服器會阻擋跨網域的XML存取,當然如果你是該網站開發者,所開發的頁面應該將會被放在被認可的網域中,不會碰到這個問題,但我們在開發前期有可能會不在所屬的網域,這樣就會造成開發上的困難,不過我們可以透過Yahoo所提供的YQL查詢語法來解決這個問題,以下就是相關的說明:
若我們在自己的電腦用以下的語法去存取一個網路上的XML
<script> $(function () { var xmlSource = "http://stanley.cloudlab.tw/crossDomainXML/testXML.xml"; $.ajax({ url: xmlSource, success: function (data) { console.log(data); } }) }) </script>
很可能會出現「No Access Control Allow Origin」的訊息:

但如果套用上YQL之後
<script> $(function(){ var xmlSource = "http://stanley.cloudlab.tw/crossDomainXML/testXML.xml"; var yqlURL = [ "http://query.yahooapis.com/v1/public/yql", "?q=" + encodeURIComponent("select * from xml where url='" + xmlSource + "'"), "&format=xml&callback=?" ].join(""); $.getJSON(yqlURL, function(data){ console.log(data) }); }) </script>

可以看到已經可以抓到XML內容,這樣可以讓我們較為方便的去開發,其他詳細的使用說明可以參考Yahoo YQL Guide。
It’s a sshame you don’t haave a donatte button! I’d mowt certainly donaate too tnis brilliant
blog! I ghess foor now i’ll settle for book-marking and addong your RSS fered to
myy Googfle account. I look fprward tto neew updates and wiol snare tis site wth myy Facebook group.
Talkk soon!
What’s uup to all, siunce I am aactually eaqger of reading thbis website’s post too be updated
regularly. It includes nijce information.
zithromax cost australia: buy zithromax – buy generic zithromax online
canadian pharmacy amoxicillin cheap amoxicillin amoxicillin 500 mg tablet
I’m gonhe tto tell my little brother, that hee shoyld also ggo to seee this webpage on egular basis too take
updated from newes news.
Hello, i thnk that i saw yoou vvisited my blog thus
i came to “return the favor”.I amm attempting
to find things too enhance mmy website!I suppose itts okk tto usee soime of your ideas!!
Всем рекомендую!таможенный брокер
https://edpills.monster/# pills for ed
super kamagra: cheap kamagra – super kamagra
tadalafil generic over the counter 80 mg tadalafil tadalafil 10 mg canadian pharmacy
Всем рекомендую!таможенный склад
Greast blog! Do you have anyy suggestiions for aspirinhg writers?
I’m hoping tto start mmy own site soon buut I’m a littke lost on everything.
Would yoou suggest starting with a free platform like WordPress oor
go foor a paidd option? Tere are sso manyy optins ouut there thst I’m cokmpletely overwhelmed ..
Anny tips? Thanks a lot!
premietany cycloserine baxter erinnerten d-cycloserine (dcs) – seromycin eye ointment [url=https://canadapharmacy-usa.com/buy-seromycin-usa.html]what is d cycloserine[/url] strafwet d-cycloserine.
http://kamagra.team/# Kamagra 100mg price
https://kamagra.team/# Kamagra 100mg
Levitra online USA fast: Generic Levitra 20mg – Levitra 20 mg for sale
what is the best ed pill what are ed drugs ed medications
tadalafil price in india: best tadalafil tablets in india – best pharmacy buy tadalafil
Всем рекомендую!поступление в международный университет
https://sildenafil.win/# sildenafil 10 mg daily
erection pills medicine erectile dysfunction male erection pills
medication for ed: erectile dysfunction medications – medicine for erectile
Всем рекомендую!подготовка к международным экзаменам
https://tadalafil.trade/# cheap tadalafil tablets
Здесь можно не дорого и качественно оформить Справка 095 у
sildenafil citrate 100: sildenafil best price canada – 20 mg sildenafil 689
Всем рекомендую!английский язык онлайн
buy Levitra over the counter Cheap Levitra online Levitra 20 mg for sale
https://tadalafil.trade/# tadalafil for sale in canada
tadalafil 10mg coupon: tadalafil online canada – buy tadalafil from india