如何调试“解析 XML 时出错:标签不匹配”?
Posted
技术标签:
【中文标题】如何调试“解析 XML 时出错:标签不匹配”?【英文标题】:How to debug "Error parsing XML: mismatched tag"? 【发布时间】:2018-03-03 15:50:02 【问题描述】:我已经关闭了标签,但它仍然给我错误,当我编译它时说:
解析 XML 时出错:标签不匹配
在 XML 复制编辑器中,它在保存“标记 PreferenceScreen 第 2 行中的数据过早结束”时对我说,请有人可以像我应该写的那样给我写代码吗?,真相我不知道我做错了,我是初学者。
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/GB_Mods"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cmwmobile="http://schemas.android.com/apk/res/com.whatsapp">
<PreferenceCategory android:title="HPWhatsApp 4.0" android:key="cat_wa">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_preguntas" android:title="HPWhatsApp WEB" android:key="settings_faq" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_actualizaciones" android:title="@string/updatess" android:key="updates_key" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_Thanks" android:title="Donar" android:summary="Donar al desarrollador" >
<intent android:action="android.intent.action.VIEW" android:data="https://paypal.me/Hectorc4rp" />
</com.whatsapp.preference.WaPreference>
<PreferenceScreen android:icon="@drawable/ic_9" android:title="Contactar al desarrollador" android:summary="Habla con Héctor Paez, creador de HPWhatsApp" >
<intent android:action="android.intent.action.VIEW" android:data="https://api.whatsapp.com/send?phone=543814805749" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/themes">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_descargar" android:title="@string/download_themes" android:key="download_themes" android:summary="@string/download_themes_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_temas" android:title="@string/more_preferences" android:key="themes_key" android:summary="@string/more_preferences_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_web" android:title="Más temas" android:summary="Descarga temas hechos por otras personas" >
<intent android:action="android.intent.action.VIEW" android:data="http://www.whatsappthemes.net/search/label/GBWhatsApp%20Themes" />
</com.whatsapp.preference.WaPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/appearance">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_1" android:title="@string/conversation_colors" android:key="chat_colors" android:summary="@string/conversation_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_2" android:title="@string/chats_colors" android:key="chats_colors" android:summary="@string/chats_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_3" android:title="@string/popup_colors" android:key="popup_key" android:summary="@string/popup_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_4" android:title="@string/widgets" android:key="widget_key" android:summary="@string/widgets_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_5" android:title="@string/media_sharing_pref" android:key="media_sharing_key" android:summary="@string/media_sharing_pref_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_6" android:title="@string/others" android:key="others_key" android:summary="@string/others_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_7" android:title="@string/gb_lock" android:key="gb_lock" />
<Preference android:icon="@drawable/ic_actualizaciones" android:title="@string/clean_whatsapp_pref" android:key="clean_whatsapp_screen" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_8" android:title="@string/read_log_pref" android:key="logs_key" />
<ListPreference android:icon="@drawable/ic_lang" android:entries="@array/language_array" android:title="@string/language_title" android:key="gb_language_key" android:defaultValue="0" android:entryValues="@array/language_values" />
<Preference android:icon="@drawable/ic_temas" android:title="@string/change_font_pref" android:key="gb_fonts" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/GB_About" android:key="cat_about">
<Preference android:icon="@drawable/ic_twitter" android:title="@string/pref_facebook" android:key="facebook" android:summary="@string/pref_sum_facebook" />
<Preference android:icon="@drawable/ic_twi" android:title="@string/google_plus" android:key="google_plus" android:summary="@string/google_plus_sum" />
<Preference android:icon="@drawable/ic_web" android:title="@string/pref_sum_blogger" android:key="about" android:summary="HPWhatsApp" />
<Preference android:icon="@drawable/ic_twitter" android:title="Página de Facebook" android:summary="Regalanos un me gusta en Facebook" >
<intent android:action="android.intent.action.VIEW" android:data="https://facebook.com/todo.para.android.hp" />
<Preference android:icon="@drawable/ic_compartir" android:title="@string/GBShare" android:key="share" android:summary="@string/GBShareSum" />
<Preference android:icon="@drawable/ic_reportar" android:title="@string/GB_Report" android:key="report" />
<Preference android:icon="@drawable/ic_Thanks" android:title="@string/Thanks" android:key="Thanks" />
</PreferenceCategory>
</PreferenceScreen>
【问题讨论】:
下次用英文提问或者去西班牙文版es.***.com 只有英文版 对话只能用英语。这样我们就可以帮助您并为您提供所需的解决方案。 【参考方案1】:您忘记在两个地方关闭“com.whatsapp.preference.WaPreference”标签。
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/GB_Mods"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cmwmobile="http://schemas.android.com/apk/res/com.whatsapp">
<PreferenceCategory android:title="HPWhatsApp 4.0" android:key="cat_wa">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_preguntas" android:title="HPWhatsApp WEB" android:key="settings_faq" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_actualizaciones" android:title="@string/updatess" android:key="updates_key" />
<!-- start <com.whatsapp.preference.WaPreference> -->
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_Thanks" android:title="Donar" android:summary="Donar al desarrollador" >
<intent android:action="android.intent.action.VIEW" android:data="https://paypal.me/Hectorc4rp" />
<!-- close your </com.whatsapp.preference.WaPreference> here -->
</com.whatsapp.preference.WaPreference>
<PreferenceScreen android:icon="@drawable/ic_9" android:title="Contactar al desarrollador" android:summary="Habla con Héctor Paez, creador de HPWhatsApp" >
<intent android:action="android.intent.action.VIEW" android:data="https://api.whatsapp.com/send?phone=543814805749" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/themes">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_descargar" android:title="@string/download_themes" android:key="download_themes" android:summary="@string/download_themes_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_temas" android:title="@string/more_preferences" android:key="themes_key" android:summary="@string/more_preferences_summary" />
<!-- start <com.whatsapp.preference.WaPreference> -->
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_web" android:title="Más temas" android:summary="Descarga temas hechos por otras personas" >
<intent android:action="android.intent.action.VIEW" android:data="http://www.whatsappthemes.net/search/label/GBWhatsApp%20Themes" />
<!-- close your </com.whatsapp.preference.WaPreference> here -->
</com.whatsapp.preference.WaPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/appearance">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_1" android:title="@string/conversation_colors" android:key="chat_colors" android:summary="@string/conversation_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_2" android:title="@string/chats_colors" android:key="chats_colors" android:summary="@string/chats_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_3" android:title="@string/popup_colors" android:key="popup_key" android:summary="@string/popup_colors_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_4" android:title="@string/widgets" android:key="widget_key" android:summary="@string/widgets_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_5" android:title="@string/media_sharing_pref" android:key="media_sharing_key" android:summary="@string/media_sharing_pref_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_6" android:title="@string/others" android:key="others_key" android:summary="@string/others_summary" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_7" android:title="@string/gb_lock" android:key="gb_lock" />
<Preference android:icon="@drawable/ic_actualizaciones" android:title="@string/clean_whatsapp_pref" android:key="clean_whatsapp_screen" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_8" android:title="@string/read_log_pref" android:key="logs_key" />
<ListPreference android:icon="@drawable/ic_lang" android:entries="@array/language_array" android:title="@string/language_title" android:key="gb_language_key" android:defaultValue="0" android:entryValues="@array/language_values" />
<Preference android:icon="@drawable/ic_temas" android:title="@string/change_font_pref" android:key="gb_fonts" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/GB_About" android:key="cat_about">
<Preference android:icon="@drawable/ic_twitter" android:title="@string/pref_facebook" android:key="facebook" android:summary="@string/pref_sum_facebook" />
<Preference android:icon="@drawable/ic_twi" android:title="@string/google_plus" android:key="google_plus" android:summary="@string/google_plus_sum" />
<Preference android:icon="@drawable/ic_web" android:title="@string/pref_sum_blogger" android:key="about" android:summary="HPWhatsApp" />
<Preference android:icon="@drawable/ic_twitter" android:title="Página de Facebook" android:summary="Regalanos un me gusta en Facebook" >
<intent android:action="android.intent.action.VIEW" android:data="https://facebook.com/todo.para.android.hp" />
<Preference android:icon="@drawable/ic_compartir" android:title="@string/GBShare" android:key="share" android:summary="@string/GBShareSum" />
<Preference android:icon="@drawable/ic_reportar" android:title="@string/GB_Report" android:key="report" />
<Preference android:icon="@drawable/ic_Thanks" android:title="@string/Thanks" android:key="Thanks" />
</PreferenceCategory>
</PreferenceScreen>
【讨论】:
【参考方案2】:内部带有intent
的com.whatsapp.preference.WaPreference
标记未关闭。例如
<PreferenceCategory android:title="HPWhatsApp 4.0" android:key="cat_wa">
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_preguntas" android:title="HPWhatsApp WEB" android:key="settings_faq" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_actualizaciones" android:title="@string/updatess" android:key="updates_key" />
<com.whatsapp.preference.WaPreference android:icon="@drawable/ic_Thanks" android:title="Donar" android:summary="Donar al desarrollador" >
<intent android:action="android.intent.action.VIEW" android:data="https://paypal.me/Hectorc4rp" />
<!--
Close the com.whatsapp.preference.WaPreference here !
-->
</com.whatsapp.preference.WaPreference>
<PreferenceScreen android:icon="@drawable/ic_9" android:title="Contactar al desarrollador" android:summary="Habla con Héctor Paez, creador de HPWhatsApp" >
<intent android:action="android.intent.action.VIEW" android:data="https://api.whatsapp.com/send?phone=543814805749" />
</PreferenceScreen>
</PreferenceCategory>
【讨论】:
以上是关于如何调试“解析 XML 时出错:标签不匹配”?的主要内容,如果未能解决你的问题,请参考以下文章
我的 GLSL 着色器程序链接正常,但是当我尝试使用它时出错——我该如何调试它?
如何调试 Helm 图表错误,例如“将 YAML 转换为 JSON 时出错:yaml:在此上下文中不允许映射值”?
使用GNU/gdb调试Linux C/C++可执行程序查看出错源代码、设置断点