From: Yuhan Z. <yz...@on...> - 2011-08-18 21:48:36
|
nvm, my own bad. Yuhan On Thu, Aug 18, 2011 at 12:50 PM, Yuhan Zhang <yz...@on...> wrote: > 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 > > |