V
VitaminB
Hello,
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...
Thanks a lot for you help.
Regards,
Marcus
##################
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);
##################
Beispiel HTML-Seite:
##################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
self._domino_name = "_Main";
// -->
</script>
</head>
<frameset cols="45%,55%">
<frame
src="/Test/HET/PerformanceTestDB.nsf/ContentDeliveryMeasurement?OpenForm">
<frameset rows="1*,1*">
<frame src="/Test/HET/PerformanceTestDB.nsf/DocsInserted?OpenView">
<frame name="docPreviewFrame"
src="/Test/HET/PerformanceTestDB.nsf/select?OpenForm">
</frameset>
</frameset>
</html>
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...
Thanks a lot for you help.
Regards,
Marcus
##################
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);
##################
Beispiel HTML-Seite:
##################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
self._domino_name = "_Main";
// -->
</script>
</head>
<frameset cols="45%,55%">
<frame
src="/Test/HET/PerformanceTestDB.nsf/ContentDeliveryMeasurement?OpenForm">
<frameset rows="1*,1*">
<frame src="/Test/HET/PerformanceTestDB.nsf/DocsInserted?OpenView">
<frame name="docPreviewFrame"
src="/Test/HET/PerformanceTestDB.nsf/select?OpenForm">
</frameset>
</frameset>
</html>