下面是我的 XML,我将使用 XMLPullParser 解析它。解析器正确地从标签中读取值,例如
<hours>Monday: 1:00 PM - 3:00 PM Thursday: 8:30 AM - 12:30 PM</hours>
但如果 webservice 没有给出计时数据,则 hours 标签为空:
<hours/>
并且 XMLPullParser 会跳过这些标签。我想从这些标签中读取空值或空字符串。
<?xml version="1.0" encoding="UTF-8"?>
<root>
<city_data>
<city_details>
<id>1</id>
<city>City1</city>
<location>5390 Park</location>
<phoneno>239-963</phoneno>
<fax>239-963</fax>
<hours>Monday: 1:00 PM - 3:00 PM Thursday: 8:30 AM - 12:30 PM</hours>
<latitude>26.2134964</latitude>
<longitude>-81.7672781</longitude>
<action>2</action>
</city_details>
</city_data>
<city_data>
<city_details>
<id>2</id>
<city>City2</city>
<location>13100 Westlinks</location>
<phoneno>239</phoneno>
<fax>239-332</fax>
<hours/>
<latitude>26.553446</latitude>
<longitude>-81.7560699</longitude>
<action>2</action>
</city_details>
</city_data>
</root>