Question

<html>
  <body class="page3078">
    <div id="mainCapsule">
      <div id="contentCapsule" class="capsule">
        <div id="content">
          <div id="subCapsule" class="clearFix" xmlns="">
            <div id="contentLeft">
              <iframe width="635" height="1000" frameborder="0" src="apps/Results.aspx">
                #document
                <html xmlns="http://www.w3.org/1999/xhtml">
                  <body style="background:none;">
                    <form id="form1" action="Results.aspx" method="post" name="form1">
                      <div class="pressContent"> 
                        <h1>Hey there</h1>
                        <div class="tableCapsule details">
                          <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tbody>
                              <tr class="even">

My query is:

Element element = doc.select("div.pressContent > h1").first();

And In here "element" is null. Is there something about iframe? or #document?

Was it helpful?

Solution

  1. You're trying to access content inside an iFrame. My understanding is jsoup does not support this. Target the iframe src directly, See: https://stackoverflow.com/a/16236780/24998 to ensure you're actually accessing the content inside the iframe.

  2. '>' in a CSS selection is for an immediate child, which doesn't seem to be the case here. You'll probably want to drop the '>' and just have a space.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top