尝试在 xhtml 文件上使用 Sax 解析器时出错
我正在尝试使用 Java 中的 SAXParser 解析 xhml 文件,但出现异常:
“java.net.MalformedURLException: 未知协议:g"
导致例外的行是:
SAXBuilder.build(Destination)
虽然 Destination 是 xhml 文件的完整路径。 xhml文件的开头如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="../article.css" type="text/css"?>
<div id="article" xmlns="http://www.w3.org/1999/xhtml">
其中div是根元素。
我尝试在网上查找有关协议 g 或 MalformedURLException 的文档, 我也尝试使用名称空间,但无法完成这项工作。
有谁知道我能做些什么来使这项工作成功?
谢谢
I'm trying to parse an xhml file using SAXParser in Java, but gets an exception:
"java.net.MalformedURLException:
unknown protocol: g"
The line made that exception was:
SAXBuilder.build(Destination)
While Destination is the full path to the xhml file.
The beginning of the xhml file is as followed:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="../article.css" type="text/css"?>
<div id="article" xmlns="http://www.w3.org/1999/xhtml">
While div is the root element.
I tried to look for documentation over the web about protocol g or MalformedURLException,
i tried to play with the namespaces as well, but couldn't get this work.
Does anyone have any idea what can i do to make this work?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(基于评论中的讨论)SAXBuilder 将“Destination”视为 URL 而不是本地文件。使用 File 对象调用“build”。
(Based on discussion in the comments) SAXBuilder is treating "Destination" as a URL and not a local file. Call "build" with a File object instead.