Xml从服务器工作,但在本地Xml文件中它不起作用?

时间:2013-03-13 04:25:49

标签: xml ajax

我从服务器获取一个xml文件,

xml文件为,

<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:georss="http://www.georss.org/georss">
    <title>Country Congressional Districts
        DC - CD    
    </title>
    <subtitle>Country Congressional Districts</subtitle>
    <id>12345-1222-12345-12345 

    </id>
    <level>district</level>
    <item>
        <title geoid='1198'>District of Columbia</title>
        <description cong_dist='Delegate District (at Large) 98'>DC - Delegate District (at Large) 98 &lt;br/&gt; No of Incidents: 1436</description>
        <latitude>38.8933115</latitude>
        <longitude>-77.0146475</longitude>
        <georss:polygon>38.934311 -77.1199 38.939834989364 -77.112868886998 38.94641 -77.1045 38.94891 -77.1007 38.95651 -77.0915 38.960871062931 -77.085827416011 38.967245703105 -77.077535703105 38.971616050926 -77.07185104194 38.98511 -77.054299 38.986557824794 -77.052373393024 38.99511 -77.040999 38.99171 -77.036299 38.98423067065 -77.026499658425 38.977828623846 -77.018111761535 38.97591 -77.015598 38.97441 -77.013798 38.97011 -77.008298 38.96541 -77.002498 38.961159688178 -76.99699924729 38.95742281319 -76.992164742828 38.951906165093 -76.985027693844 38.946183221387 -76.977623754198 38.93511031877 -76.963298416241 38.930758817183 -76.957668751373 38.918592133391 -76.941928356721 38.913311 -76.935096 38.910455906543 -76.931516373827 38.904209815545 -76.923685221832 38.904084963804 -76.923528686655 38.895811472659 -76.913155644266 38.892812 -76.909395 38.891712 -76.910795 38.889812 -76.913241969697 38.88563612178 -76.918619994677 38.885112 -76.919295 38.884412 -76.920195 38.881242218815 -76.92424312618 38.872907653617 -76.934887195786 38.863761708777 -76.946567477982 38.861312 -76.949696 38.858512 -76.953696 38.8521000076 -76.961688068401 38.8509022261 -76.963181013352 38.849315084168 -76.965159266926 38.848223201534 -76.966520216871 38.843212171615 -76.972766090443 38.837812 -76.979497 38.834059579904 -76.984657115143 38.829116489263 -76.991454572844 38.828213 -76.992697 38.821913 -76.999997 38.821513 -77.001397 38.815196806563 -77.009229290402 38.791513 -77.038598 38.815196806563 -77.009229290402 38.821513 -77.001397 38.821913 -76.999997 38.828213 -76.992697 38.829116489263 -76.991454572844 38.834059579904 -76.984657115143 38.837812 -76.979497 38.843212171615 -76.972766090443 38.848223201534 -76.966520216871 38.849315084168 -76.965159266926 38.8509022261 -76.963181013352 38.8521000076 -76.961688068401 38.858512 -76.953696 38.861312 -76.949696 38.863761708777 -76.946567477982 38.872907653617 -76.934887195786 38.881242218815 -76.92424312618 38.884412 -76.920195 38.885112 -76.919295 38.88563612178 -76.918619994677 38.889812 -76.913241969697 38.891712 -76.910795 38.892812 -76.909395 38.895811472659 -76.913155644266 38.904084963804 -76.923528686655 38.904209815545 -76.923685221832 38.910455906543 -76.931516373827 38.913311 -76.935096 38.918592133391 -76.941928356721 38.930758817183 -76.957668751373 38.93511031877 -76.963298416241 38.946183221387 -76.977623754198 38.951906165093 -76.985027693844 38.95742281319 -76.992164742828 38.961159688178 -76.99699924729 38.96541 -77.002498 38.97011 -77.008298 38.97441 -77.013798 38.97591 -77.015598 38.977828623846 -77.018111761535 38.98423067065 -77.026499658425 38.99171 -77.036299 38.99511 -77.040999 38.986557824794 -77.052373393024 38.98511 -77.054299 38.971616050926 -77.07185104194 38.967245703105 -77.077535703105 38.960871062931 -77.085827416011 38.95651 -77.0915 38.94891 -77.1007 38.94641 -77.1045 38.939834989364 -77.112868886998 38.934311 -77.1199</georss:polygon>
    </item>
    <item>
        <title geoid='1198'>District of Columbia</title>
        <description cong_dist='Delegate District (at Large) 98'>DC - Delegate District (at Large) 98 &lt;br/&gt; No of Incidents: 1436</description>
        <latitude>38.8933115</latitude>
        <longitude>-77.01464758888888</longitude>
        <georss:polygon>38.881242218815 -76.92424312618 38.872907653617 -76.934887195786 38.863761708777 -76.946567477982 38.861312 -76.949696 38.858512 -76.953696 38.8521000076 -76.961688068401 38.8509022261 -76.963181013352 38.849315084168 -76.965159266926 38.848223201534 -76.966520216871 38.843212171615 -76.972766090443 38.837812 -76.979497 38.834059579904 -76.984657115143 38.829116489263 -76.991454572844 38.828213 -76.992697 38.821913 -76.999997 38.821513 -77.001397 38.815196806563 -77.009229290402 38.791513 -77.038598 38.800813 -77.038898 38.814913 -77.035798 38.815613 -77.038098 38.819504901512 -77.038769017502 38.821413 -77.039098 38.828612 -77.038098 38.832212 -77.039199 38.833712 -77.041199 38.833812 -77.042599 38.833212 -77.043499 38.834712 -77.044899 38.838512 -77.044999 38.840212 -77.044199 38.840212 -77.041699 38.841712 -77.032798 38.850512 -77.031698 38.864312 -77.039299 38.865812 -77.038899 38.868112 -77.039099 38.871212 -77.040599 38.874012 -77.043299 38.875212 -77.045399 38.874912 -77.046599 38.873012 -77.045599 38.871312 -77.046299 38.870712 -77.049099 38.873212 -77.051299 38.875212 -77.051099 38.879112 -77.054099 38.880012 -77.055199 38.880069 -77.058254 38.888611 -77.063499 38.891090343863 -77.064387821385 38.899211 -77.067299 38.899811 -77.068199 38.900711 -77.070099 38.901463734213 -77.077689697258 38.901911 -77.0822 38.904211 -77.0902 38.905911 -77.0937 38.911111 -77.1012 38.912911 -77.1034 38.916393146652 -77.105028746015 38.919111 -77.1063 38.925211 -77.1134 38.928911 -77.1166 38.932411 -77.1179 38.934311 -77.1199 38.939834989364 -77.112868886998 38.94641 -77.1045 38.94891 -77.1007 38.95651 -77.0915 38.960871062931 -77.085827416011 38.967245703105 -77.077535703105 38.971616050926 -77.07185104194 38.98511 -77.054299 38.986557824794 -77.052373393024 38.99511 -77.040999 38.99171 -77.036299 38.98423067065 -77.026499658425 38.977828623846 -77.018111761535 38.97591 -77.015598 38.97441 -77.013798 38.97011 -77.008298 38.96541 -77.002498 38.961159688178 -76.99699924729 38.95742281319 -76.992164742828 38.951906165093 -76.985027693844 38.946183221387 -76.977623754198 38.93511031877 -76.963298416241 38.930758817183 -76.957668751373 38.918592133391 -76.941928356721 38.913311 -76.935096 38.910455906543 -76.931516373827 38.904209815545 -76.923685221832 38.904084963804 -76.923528686655 38.895811472659 -76.913155644266 38.892812 -76.909395 38.891712 -76.910795 38.889812 -76.913241969697 38.88563612178 -76.918619994677 38.885112 -76.919295 38.884412 -76.920195 38.881242218815 -76.92424312618</georss:polygon>
    </item>
</feed>

当我复制xml并将其放在XML文件中时。

通过使用ajax调用我得到了响应,

但是Xml flie无法产生结果。

它出错了。

我必须为此做些什么..,

我的问题为[SUBJECT]

来自服务器的xml正在运行,我将xml复制到一个文件中,然后使用ajax我得到了xml值,它运行不正常。

我必须为此做些什么?????

1 个答案:

答案 0 :(得分:0)

我的所有验证工作都很棒...我会尝试使用collapsar所说的并添加一个序言:<?xml version="1.0" encoding="UTF-8"?>。如果这不起作用,也许尝试发布您的AJAX,我们可以看看错误是否存在!