From: Yuhan Z. <yz...@on...> - 2011-08-18 19:50:11
|
Hi all, I'm having some trouble with parsing html string directly through inputSource. It appears that DOMParser.parse(uri) works properly, but DOMParse.parse(inputSource) always return a DOM element with [#document: null] inside. Can someone take a look on how I did it wrong? thanks! Here is how I did it: DOMParser parser = new DOMParser(); InputSource inputSource = new InputSource(); inputSource.setCharacterStream(new StringReader(xml)); parser.parse(inputSource); doc = parser.getDocument(); This doesn' work either: DOMParser parser = new DOMParser(); InputSource inputSource = new InputSource( new ByteArrayInputStream(xml.getBytes()) ); parser.parse(inputSource); doc = parser.getDocument(); Yuhan |