当前位置: 代码迷 >> Android >> 关于Android获取解析XML的有关问题
  详细解决方案

关于Android获取解析XML的有关问题

热度:95   发布时间:2016-05-01 21:00:02.0
关于Android获取解析XML的问题
各位,目前我们项目中有一个 获取XML中的 
<latlng>45.515917,-122.674833</latlng> 
其中45.515917,-122.674833是我们工作人员的纬度和经度。
而服务器地址是 35.515917,-122.674833

我在android中能够获取到xml但是解析的时候总是出问题
因此,我把XML贴上来,求大虾帮我解析下XML,哈哈,最好
能将我服务器的地址,和解析到工作人员的地址对比下,
弹出离服务器最近的工作人员地址。谢谢!

XML code
<sites><copyright> Copyright ? 2002-2011 Thomas W. Dowling.  All rights reserved.   For more info, contact  [email protected] or call 916-988-3459. </copyright><freshness>    1/30/2011   11:43:02 PM  PT    </freshness><site><id>97204_1</id><name>Downtown Portland</name><latlng>45.515917,-122.674833</latlng><status>Up</status><action>OK</action><pay>no</pay><restricted>no</restricted><address>SW Salmon St. at SW 1st Ave.</address><city>aos, Portland, OR</city><county>Multnomah</county><othercond number="2" up="2"/></site><site><id>94501_4</id><name>Alameda City Parking Lot</name><latlng>37.76843,-122.24595</latlng><status>Up</status><action>OK</action><pay>no</pay><restricted>yes</restricted><address>Lincoln Ave. at Walnut Ave</address><city>bay, Alameda, CA</city><county>Alameda</county><avc number="4" up="4"/></site><site><id>94501_1</id><name>Bank of Alameda</name><latlng>37.76014,-122.2518</latlng><status>Down</status><action>DOWN LOC</action><pay>no</pay><restricted>no</restricted><address>2130 Otis Drive</address><city>bay, Alameda, CA</city><county>Alameda</county><lpi number="1" down="1"/><avc number="1" down="1"/></site><site><id>92311_1</id><name>Barstow Station</name><latlng>34.891320,-116.999312</latlng><status>Up</status><action>NEW LOC</action><pay>no</pay><restricted>no</restricted><address>1611 E. Main St.</address><city>sbo, Barstow, CA</city><county>San Bernardino</county><othercond number="1" up="1"/><tsl number="1" up="1"/></site></sites>



------解决方案--------------------
你用IE看看能否打开,如果打不开就是格式不对
------解决方案--------------------
就一个简单的xml文件解析,网上很多demo啊!

把你出现的错误贴出来!帮你看看吧!

可以发过来帮你看看
[email protected]
------解决方案--------------------
同意楼上说法
------解决方案--------------------
我用了你的源码测试了下,解析没有问题呀,是不是你自己弄错了?

我用的是SAX的

XML code
<sites><copyright> Copyright ? 2002-2011 Thomas W. Dowling.  All rights reserved.   For more info, contact  [email protected] or call 916-988-3459. </copyright><freshness>    1/30/2011   11:43:02 PM  PT    </freshness><site><id>97204_1</id><name>Downtown Portland</name><latlng>45.515917,-122.674833</latlng><status>Up</status><action>OK</action><pay>no</pay><restricted>no</restricted><address>SW Salmon St. at SW 1st Ave.</address><city>aos, Portland, OR</city><county>Multnomah</county><othercond number="2" up="2"/></site><site><id>94501_4</id><name>Alameda City Parking Lot</name><latlng>37.76843,-122.24595</latlng><status>Up</status><action>OK</action><pay>no</pay><restricted>yes</restricted><address>Lincoln Ave. at Walnut Ave</address><city>bay, Alameda, CA</city><county>Alameda</county><avc number="4" up="4"/></site><site><id>94501_1</id><name>Bank of Alameda</name><latlng>37.76014,-122.2518</latlng><status>Down</status><action>DOWN LOC</action><pay>no</pay><restricted>no</restricted><address>2130 Otis Drive</address><city>bay, Alameda, CA</city><county>Alameda</county><lpi number="1" down="1"/><avc number="1" down="1"/></site><site><id>92311_1</id><name>Barstow Station</name><latlng>34.891320,-116.999312</latlng><status>Up</status><action>NEW LOC</action><pay>no</pay><restricted>no</restricted><address>1611 E. Main St.</address><city>sbo, Barstow, CA</city><county>San Bernardino</county><othercond number="1" up="1"/><tsl number="1" up="1"/></site></sites>
  相关解决方案