我目前正在解析一个包含大量地理数据的 XML 文件。
基本上,该文件包含一个城市列表,其中可能包含此外语替代名称示例列表。显示的示例显示了柏林的替代名称列表:
<alternateName lang="af">Berlyn</alternateName>
<alternateName lang="als">Berlin</alternateName>
<alternateName lang="an">Berlín</alternateName>
<alternateName lang="ang">Berlin</alternateName>
<alternateName lang="ar">برلين</alternateName>
<alternateName lang="arc">ܒܪܠܝܢ</alternateName>
<alternateName lang="ast">Berlín</alternateName>
<alternateName lang="bar">Berlin</alternateName>
<alternateName lang="be">Бэрлін</alternateName>
<alternateName lang="bg">Берлин</alternateName>
<alternateName lang="bn">বার্লিন</alternateName>
<alternateName lang="br">Berlin</alternateName>
<alternateName lang="bs">Berlin</alternateName>
<alternateName lang="ca">Estat de Berlín</alternateName>
<alternateName lang="cs">Berlín</alternateName>
<alternateName lang="csb">Berlëno</alternateName>
<alternateName lang="cv">Берлин</alternateName>
<alternateName lang="cy">Berlin</alternateName>
<alternateName lang="da">Berlin</alternateName>
<alternateName lang="de">Berlin</alternateName>
<alternateName lang="el">Βερολίνο</alternateName>
<alternateName lang="en">Berlin</alternateName>
<alternateName lang="eo">Berlino</alternateName>
<alternateName lang="es">Berlín</alternateName>
<alternateName lang="et">Berliin</alternateName>
<alternateName lang="eu">Berlin</alternateName>
<alternateName lang="fa">برلین</alternateName>
<alternateName lang="fi">Berliini</alternateName>
<alternateName lang="fo">Berlin</alternateName>
<alternateName lang="fr">Berlin</alternateName>
<alternateName lang="ga">Beirlín</alternateName>
<alternateName lang="gd">Berlin</alternateName>
<alternateName lang="gl">Berlín</alternateName>
<alternateName lang="hbs">Berlin</alternateName>
<alternateName lang="he">ברלין</alternateName>
<alternateName lang="hr">Berlin</alternateName>
<alternateName lang="hu">Berlin</alternateName>
<alternateName lang="hy">Բերլին</alternateName>
<alternateName lang="ia">Berlin</alternateName>
<alternateName lang="iata">BER</alternateName>
<alternateName lang="id">Berlin</alternateName>
<alternateName lang="io">Berlin</alternateName>
<alternateName lang="is">Berlín</alternateName>
<alternateName lang="it">Berlino</alternateName>
<alternateName lang="ja">ベルリン</alternateName>
<alternateName lang="jv">Berlin</alternateName>
<alternateName lang="ka">ბერლინი</alternateName>
<alternateName lang="ko">베를린</alternateName>
<alternateName lang="ku">Berlîn</alternateName>
<alternateName lang="kw">Berlin</alternateName>
<alternateName lang="la">Berolinum</alternateName>
<alternateName lang="lb">Berlin</alternateName>
<alternateName lang="li">Berlien</alternateName>
<alternateName lang="link">http://en.wikipedia.org/wiki/Berlin</alternateName>
<alternateName lang="lt">Berlynas</alternateName>
<alternateName lang="lv">Berlīne</alternateName>
<alternateName lang="mk">Берлин</alternateName>
<alternateName lang="mr">बर्लिन</alternateName>
<alternateName lang="ms">Berlin</alternateName>
<alternateName lang="nds">Berlin</alternateName>
<alternateName lang="nl">Berlijn</alternateName>
<alternateName lang="nn">Berlin</alternateName>
<alternateName lang="no">Berlin</alternateName>
<alternateName lang="nrm">Bèrlîn</alternateName>
<alternateName lang="oc">Berlin</alternateName>
<alternateName lang="pdc">Berlin</alternateName>
<alternateName lang="pl">Berlin</alternateName>
<alternateName lang="pms">Berlin</alternateName>
<alternateName lang="pt">Berlim</alternateName>
<alternateName lang="qu">Berlin</alternateName>
<alternateName lang="rm">Berlin</alternateName>
<alternateName lang="ro">Berlin</alternateName>
<alternateName lang="ru">Берлин</alternateName>
<alternateName lang="scn">Birlinu</alternateName>
<alternateName lang="sk">Berlín</alternateName>
<alternateName lang="sl">Berlin</alternateName>
<alternateName lang="sq">Berlini</alternateName>
<alternateName lang="sr">Берлин</alternateName>
<alternateName lang="sv">Berlin</alternateName>
<alternateName lang="sw">Berlin</alternateName>
<alternateName lang="ta">பெர்லின்</alternateName>
<alternateName lang="th">เบอร์ลิน</alternateName>
<alternateName lang="tr">Berlin</alternateName>
<alternateName lang="ty">Berlin</alternateName>
<alternateName lang="ug">بېرلىن</alternateName>
<alternateName lang="uk">Берлін</alternateName>
<alternateName lang="vi">Berlin</alternateName>
<alternateName lang="vo">Berlin</alternateName>
<alternateName lang="yi">בערלין</alternateName>
<alternateName lang="zh">柏林</alternateName>
XML 标头如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
解析本身工作得很好,除了许多名称由于格式问题而没有正确显示。我尝试了 UTF-8 编码但没有成功。
我现在的问题是对数据进行编码以便正确显示的正确方法是什么?
提前致谢!