如何查找 XML 文件中的错误?
有时,当我尝试运行代码时,Eclipse 控制台会显示:
XML 文件中出现错误:正在中止构建。
这意味着我的主 XML 文件中有一个错误。有没有什么方法可以找到我的错误,而无需进行猜测和删除一些 XML 代码来查看问题出在哪里?比如验证我的 XML 文件!谢谢。
Sometimes when I'm trying to run my code, the Eclipse console says:
Error in an XML file: aborting build.
That means that I have a mistake in my main XML file. Is there any way to find my mistake without making guesses and erasing some XML code in order to see where the problem is? Something like validation of my XML file! Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
XML 工具,一个插件for Notepad++ 允许您检查 XML 语法是否损坏并告诉您错误在哪一行。
要安装 XML 工具插件,请下载插件 zip 文件,并将内容解压到您安装 Notepad++ 的位置(例如 C:\Program Files\Notepad++)。然后重新启动Notepad++,打开要检查的XML文件,单击顶部的“插件”菜单,选择“XML工具”,然后单击“立即检查XML语法”。
希望有帮助。
XML Tools, a plugin for Notepad++ allows you to check if the XML syntax is broken and tells you on what line the error is.
To install the XML tools plugin, download the plugin zip file, and extract the contents to where you have installed Notepad++ (such as C:\Program Files\Notepad++). Then restart Notepad++, open the XML file you wish to check, click on the "Plugins" menu at the top, select "XML Tools" and click on "Check XML syntax now."
Hope that helps.
您甚至可以在 Firefox 中打开它,如果格式错误,它会显示错误所在。
You could even open it in firefox, and if it is malformed it will show you where the error lies.
不能肯定地说这是否是相同的问题,但我有时会使用 xml 文件作为活动窗口运行我的应用程序,这会创建一个中止构建。确保您没有运行 xml 文件。
Can't say for sure if it is same issue but I have on occasion Run my application with an xml file as the active window and that creates an abort build. Make sure your not Running an xml file.
我认为 Notepad++ 会报告错误后的第一行,Notepad++ 知道之前一定有错误。
我刚刚使用 Notepad++ 和 XML Tools 来调查一个文件,结果发现该文件有大约 30 个“单位翻转”错误。例如,“text:p”显示为“text:q”; “table-cell”显示为“table:cdll”和“>”显示为“=”等。
最初我认为错误一定是在报告行之前的匹配标签部分中。然而,由于有如此多的错误,我正在寻找报告错误行上方一百或两百行以及紧邻前面的匹配标签部分上方的问题。
我推断如果结束“>”如果已转换为“=”,则 Notepad++ 将读取后面的大部分内容作为自由文本。
我发现 XML 复制编辑器更容易使用,因为它发现每一行都有错误。我需要先使用 Notepad++ 进行漂亮的打印。
I think that Notepad++ reports the first line after the error(s) at which Notepad++ knows there must be an error earlier.
I have just used Notepad++ and XML Tools to investigate a file which turned out to have about 30 "single bit flipped" errors. For example, "text:p" appeared as "text:q"; "table-cell" appeared as "table:cdll" and ">" appeared as "=" etc.
Initially I thought that the error must be in the matched tags section immediately preceding the reported line. However, with so many errors I was looking for problems a hundred or two hundred lines above the reported error line and well above the immediately preceding matched tags section.
I reasoned that if an end ">" had been converted to "=" then Notepad++ would be reading much that followed as free text.
I found XML Copy Editor much easier to use as it found each line with an error. I needed to pretty print first using Notepad++.