Note that there are some explanatory texts on larger screens.

plurals
  1. PONull Pointer Exception with Jsoup Parse
    primarykey
    data
    text
    <p>So I have sifted thought some code and cannot trouble shoot this null pointer exception error. </p> <p>I'm trying to parse a tables from source code lines 2290 to 3153 <a href="http://pastebin.com/DjGHED5t" rel="nofollow">http://pastebin.com/DjGHED5t</a></p> <p>However, in one of my CSS queries the code fails and makes no sense to me why. </p> <pre><code>public void updateCompanyIs()throws IOException{ investoolsLogin(); Document doc = Jsoup.connect("http://toolbox.investools.com/graphs/fundamentalAnalysis.iedu?report=BS&amp;symbol="+(Ticker)).get(); // Elements table = doc.select("table"); /**LINE 72**/ Elements columns = doc.getElementById("fundamentalsForm").children().select("table").get(0).select("tr").get(0).select("td"); Iterator&lt;Element&gt; columnIterator = columns.iterator(); int col = 0; int row = 0; while (columnIterator.hasNext()) { Element column = columnIterator.next(); Elements rows = column.select("table").get(0).select("tr"); Iterator&lt;Element&gt; rowsIterator = rows.iterator(); col = col + 1; while (rowsIterator.hasNext()){ row = row + 1; //Element rowIterator.next = ; incomeStatementInfo[col][row] = rowsIterator.next(); } } } public void updateCompanyBs()throws IOException{ investoolsLogin(); Document doc = Jsoup.connect("http://toolbox.investools.com/graphs/fundamentalAnalysis.iedu?report=BS&amp;symbol="+(Ticker)).get(); // Elements table = doc.select("table"); Elements columns = doc.getElementById("fundamentalsForm").children().select("table").get(0).select("tr").get(0).select("td"); Iterator&lt;Element&gt; columnIterator = columns.iterator(); int col = 0; int row = 0; while (columnIterator.hasNext()) { Element column = columnIterator.next(); Elements rows = column.select("table").get(0).select("tr"); Iterator&lt;Element&gt; rowsIterator = rows.iterator(); col = col + 1; while (rowsIterator.hasNext()){ row = row + 1; //Element rowIterator.next = ; balanceSheetInfo[col][row] = rowsIterator.next(); } } } public void updateCompanyCf()throws IOException{ investoolsLogin(); Document doc = Jsoup.connect("http://toolbox.investools.com/graphs/fundamentalAnalysis.iedu?report=BS&amp;symbol="+(Ticker)).get(); // Elements table = doc.select("table"); Elements columns = doc.getElementById("fundamentalsForm").children().select("table").get(0).select("tr").get(0).select("td"); Iterator&lt;Element&gt; columnIterator = columns.iterator(); int col = 0; int row = 0; while (columnIterator.hasNext()) { Element column = columnIterator.next(); Elements rows = column.select("table").get(0).select("tr"); Iterator&lt;Element&gt; rowsIterator = rows.iterator(); col = col + 1; while (rowsIterator.hasNext()){ row = row + 1; //Element rowIterator.next = ; cashFlowsInfo[col][row] = rowsIterator.next(); } } } public void updateCompanyInfo(String Ticker) throws IOException { /** LINE 134**/ updateCompanyIs(); updateCompanyBs(); updateCompanyCf(); } } </code></pre> <p>This is the error: </p> <pre><code>Exception in thread "main" java.lang.NullPointerException at Company.updateCompanyIs(Company.java:72) at Company.updateCompanyInfo(Company.java:134) at Company.&lt;init&gt;(Company.java:41) at AppGUI.main(AppGUI.java:124) </code></pre> <p>And this is my AppGUI:</p> <pre><code>public static void main(String[] args) throws Exception{ Company company = new Company("KO"); // Creates new Company. Updating methods are called from constructor automatically. AppGUI frame = new AppGUI(company); // Creates new App GUI. Various panes are initialized from constructor. frame.retrieveGUI(company); frame.setTitle("Financial Calculator | Ratios"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(1000, 500)); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } </code></pre> <p>I think my JSOUP code is correct, but I could have gotten confused with the select and node elements, as well as the query. If anyone can help it would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload