开发者

Error while trying to use Sax Parser on xhtml file

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 fo开发者_开发技巧llowed:

<?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


(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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜