0

I have a source code in a database field. It's a 3000 line code. I'm only interested in some fields of this source code, not all the code. The code is something like this (obviously I only posted a few lines to you):

<table cellspacing="1" cellpadding="1" class="troop_details inReturn"
    >
        <thead>
            <tr>
                <td class="role">
                                            <a href="/karte.php?d=91628">01] #AfaccRoCap!</a>
                                    </td>
                <td colspan="11" class="troopHeadline">
                                                                <a href="/karte.php?d=94829">Return from 0-New Hulk</a>
                                    </td>
            </tr>
        </thead>
        <tbody class="units">
            <tr>
                <th class="coords">
                                            &#x202d;<span class="coordinates coordinatesWrapper coordinatesAligned coordinatesltr"><span class="coordinateX">(&#x202d;&minus;&#x202d;1&#x202c;&#x202c;</span><span class="coordinatePipe">|</span><span class="coordinateY">&#x202d;&minus;&#x202d;28&#x202c;&#x202c;)</span></span>&#x202c;                                    </th>
                                    <td class="uniticon">
                        <img class="unit u21" title="Phalanx: 0:45:33" alt="Phalanx" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u22" title="Swordsman: 0:53:09" alt="Swordsman" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u23" title="Pathfinder: 0:18:46" alt="Pathfinder" src="/img/x.gif" />                  </td>
                                    <td class="uniticon">
                        <img class="unit u24" title="Theutates Thunder: 0:16:47" alt="Theutates Thunder" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u25" title="Druidrider: 0:19:56" alt="Druidrider" src="/img/x.gif" />                  </td>
                                    <td class="uniticon">
                        <img class="unit u26" title="Haeduan: 0:24:32" alt="Haeduan" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u27" title="Ram: 1:19:44" alt="Ram" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u28" title="Trebuchet: 1:46:18" alt="Trebuchet" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u29" title="Chieftain: 1:03:47" alt="Chieftain" src="/img/x.gif" />                    </td>
                                    <td class="uniticon">
                        <img class="unit u30" title="Settler: 1:03:47" alt="Settler" src="/img/x.gif" />                    </td>
                                                    <td class="uniticon last">
                        <img class="unit uhero" title="Hero" alt="Hero" src="/img/x.gif" />                 </td>
                            </tr>
        </tbody>

        <tbody class="units last">
            <tr>
                <th>Troops</th>
                                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit">
                                                    340                                         </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none">
                                                    0                                           </td>
                                    <td class="unit none last">
                                                    0                                           </td>
                            </tr>
        </tbody>

                    <tbody class="infos">
                <tr>
                    <th>Bounty</th>
                    <td colspan="11">
                        <div class="res">
                            <div class="inlineIconList resourceWrapper"><div class="inlineIcon resources" title="Lumber"><i class="r1"></i><span class="value ">6066</span></div><div class="inlineIcon resources" title="Clay"><i class="r2"></i><span class="value ">5509</span></div><div class="inlineIcon resources" title="Iron"><i class="r3"></i><span class="value ">4345</span></div><div class="inlineIcon resources" title="Crop"><i class="r4"></i><span class="value ">9580</span></div></div>                        </div>
                        <div class="carry">
                            <img class="carry full" title="carry"
                                 alt="carry"
                                 src="/img/x.gif"/> &#x202d;&#x202d;25500&#x202c;&nbsp;/&nbsp;&#x202d;25500&#x202c;&#x202c;                     </div>
                    </td>
                </tr>
            </tbody>
        
        <tbody class="infos">
            <tr>
                <th>Arrival</th>
                <td colspan="11">
                    <div class="in">in&nbsp;<span  class="timer" counting="down" value="451">0:07:31</span>&nbsp;hrs.</div>
                    <div class="at"><span>at&nbsp;20:16:39</span><span> </span></div>
                </td>
            </tr>
        </tbody>
    </table>
            <a name="at"></a>

In particular, I would be interested in collecting some data, for example 01] #AfaccRoCap!:

<a href="/karte.php?d=91628">01] #AfaccRoCap!</a>

and Return from 0-New Hulk here:

<a href="/karte.php?d=94829">Return from 0-New Hulk</a>

and for example 20:16:39 here:

<td colspan="11">
                    <div class="in">in&nbsp;<span  class="timer" counting="down" value="451">0:07:31</span>&nbsp;hrs.</div>
                    <div class="at"><span>at&nbsp;20:16:39</span><span> </span></div>
                </td>

How can I withdraw them? thanks a lot

Luigi
  • 17
  • 4
  • 1
    Does this answer your question? [How do you parse and process HTML/XML in PHP?](https://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – Sharky Feb 14 '21 at 19:45
  • yes however what i can't understand is how to access the source code i saved in the database. How do I get objects from a variable (because all the source code is contained in a variable). I don't know if I've made myself clear. All the code you see above I have it in a database field, how do I search for an object in this database field? – Luigi Feb 14 '21 at 20:30
  • Get the out of the database and into a string, and then proceed to use one of the HTML libraries mentioned in Sharky's link in order to interpret the HTML in your string, and be able to identify and extract items from within it. – ADyson Feb 14 '21 at 23:07

0 Answers0