Note that there are some explanatory texts on larger screens.

plurals
  1. POAppend Row To An HTML File
    text
    copied!<p>I have a HTML file that contains a table with a variable amount of row. I'd like to be able to open that file, select the table, append a row (the amount of columns is fixed), and write this back to file file. I'm not quire sure how to proceed. </p> <p>UPDATED: Here's a simplified but HTML-valid file:</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;Light Template&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div class="starter-template"&gt; &lt;h1&gt;CTS QA Test Report&lt;/h1&gt; &lt;p id="suiteintrotext"&gt;&lt;/p&gt; &lt;h1&gt;Summary&lt;/h1&gt; &lt;table class="table" id="summarytable"&gt; &lt;tr&gt; &lt;th&gt;#&lt;/th&gt; &lt;th&gt;Test Name&lt;/th&gt; &lt;th&gt;Author&lt;/th&gt; &lt;th&gt;Start/End time (dur.)&lt;/th&gt; &lt;th&gt;Avg. CPU%&lt;/th&gt; &lt;th&gt;Pass&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;one&lt;/td&gt; &lt;td&gt;two&lt;/td&gt; &lt;td&gt;three&lt;/td&gt; &lt;td&gt;four&lt;/td&gt; &lt;td&gt;five&lt;/td&gt; &lt;td&gt;six&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The second row is there to get some data for the step-by-step troubleshooting in Eclipse</p> <p>This is as far as I managed to go in Java:</p> <pre><code>public void appendRow() throws ParserConfigurationException{ File source = new File(this.Path); Document report = null; try { report = Jsoup.parse(source, "UTF-8"); } catch (IOException e) { System.out.println("Unable to open ["+source.getAbsolutePath()+"] for parsing!"); } Elements table = report.select("#summarytable"); // Create row and td elements add append? } </code></pre> <p>My problem at this point is how to add a row, which itself should have more elements (the cells/columns). The problem right after that point would be how to save this in the HTML file?</p>
 

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