s********t 发帖数: 4150 | 1 【 以下文字转载自 Java 讨论区,原文如下 】
发信人: SmartAgent (sigh...), 信区: Java
标 题: XML parsing problem
发信站: The unknown SPACE (Tue Jan 2 02:00:05 2001) WWW-POST
Trying to parse XML file with IBM's XML4J, but it just
doesn't work. Any masters to give some advice?
The code:
DOMParser parser = new DOMParser();
parser.parse("index.xml");
Document document = parser.getDocument();
Element doc = (Element)document.getDocumentElement();
...
The XML file: (It doesn't refer to the dtd file as it is,
but it won't work ei | w******r 发帖数: 55 | 2 what do you mean by "doesn't work"? no output at all? or
some error message?
first to make sure you have some important methods for DOM
parser to parse,
like switch(node.getNodeType){case ....; case ....}
all the handlers are not free lunch -- you gotta make them
yourself.
【在 s********t 的大作中提到】 : 【 以下文字转载自 Java 讨论区,原文如下 】 : 发信人: SmartAgent (sigh...), 信区: Java : 标 题: XML parsing problem : 发信站: The unknown SPACE (Tue Jan 2 02:00:05 2001) WWW-POST : Trying to parse XML file with IBM's XML4J, but it just : doesn't work. Any masters to give some advice? : The code: : DOMParser parser = new DOMParser(); : parser.parse("index.xml"); : Document document = parser.getDocument();
|
|