troubleshooting Question

How to extract data from HTML table

Avatar of Billy Ma
Billy MaFlag for Hong Kong asked on
16 Comments1 Solution224 ViewsLast Modified:
I have some HTML code below, I want to do the following in Java, anyone can help?
For each <table></table>, it will set the array's i position, get the data from each <td></td>, then store it in an array's j position
So finally, I will get a 2D array, e.g. array[i][j]

array[0][0] = Index
array[0][1] = CM MAC
array[0][2] = Uid
array[0][3] = IP
array[0][4] = RX
array[0][5] = TX
array[0][6] = SNR

array[1][0] = 003
array[1][1] = 000CE52A7788
array[1][2] = Upstream 1
array[1][3] =
array[1][4] = -7.1
array[1][5] = 59.3
array[1][6] = 36.1

<table border='0' width='70%'>
<tr bgcolor='#F7EDA6' FONT="courier">
   <td width='8%' align='center'>Index</td>
   <td width='20%' align='center'>CM MAC</td>
   <td width='20%' align='center'>Uid</td>
   <td width='22%' align='center'>IP</td>
   <td width='10%' align='center'>RX</td>
   <td width='10%' align='center'>TX</td>
   <td width='10%' align='center'>SNR</td>
<table border='0' width='70%'>
<tr bgcolor='#b4b4b4'>
   <td width='8%' align='center'>0003</td>
   <td width='20%' align='center'>000CE52A7788</td>
   <td width='20%' align='center'>Upstream 1</td>
   <td width='22%' align='center'></td>
   <td width='10%' align='center'>-7.1</td>
   <td width='10%' align='center'>59.3</td>
   <td width='10%' align='center'>36.1</td>
<table border='0' width='70%'>
<tr bgcolor='#b4b4b4'>
   <td width='8%' align='center'>0005</td>
   <td width='20%' align='center'>000E5CE42AF2</td>
   <td width='20%' align='center'>Upstream 0</td>
   <td width='22%' align='center'></td>
   <td width='10%' align='center'>-2.1</td>
   <td width='10%' align='center'>58.5</td>
   <td width='10%' align='center'>36.2</td>

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros