Jump to content

How to extract the HTML code?


j5

Recommended Posts

Below is the content read from HTML file

 

<tr align=left><td colspan=14><b>Closed Transactions:</b></td></tr>
<tr align=center bgcolor="#C0C0C0">
   <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
   <td>Price</td><td>S / L</td><td>T / P</td><td nowrap>Close Time</td>
   <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>
<tr align=right><td title="DEPOSIT VIA LOCAL DEPOSITOR">4435945</td><td class=msdate nowrap>2009.12.14 00:42</td><td>balance</td><td colspan=10 align=left>DEPOSIT VIA LOCAL DEPOSITOR</td><td class=mspt>100.00</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="WELCOME BONUS">4438265</td><td class=msdate nowrap>2009.12.14 01:49</td><td>balance</td><td colspan=10 align=left>WELCOME BONUS</td><td class=mspt>20.00</td></tr>
<tr align=right><td title="#61 ">4513245</td><td class=msdate nowrap>2009.12.16 03:58</td><td>buy</td><td class=mspt>0.48</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4528</td><td style="mso-number-format:0\.0000;">1.4486</td><td style="mso-number-format:0\.0000;">1.4578</td><td class=msdate nowrap>2009.12.16 05:00</td><td style="mso-number-format:0\.0000;">1.4535</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.36</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#41 [sl]">4549667</td><td class=msdate nowrap>2009.12.17 01:12</td><td>buy</td><td class=mspt>0.50</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4513</td><td style="mso-number-format:0\.0000;">1.4471</td><td style="mso-number-format:0\.0000;">1.4563</td><td class=msdate nowrap>2009.12.17 01:49</td><td style="mso-number-format:0\.0000;">1.4471</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-21.00</td></tr>
<tr align=right><td title="#21 ">4591750</td><td class=msdate nowrap>2009.12.17 19:16</td><td>sell</td><td class=mspt>0.41</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4346</td><td style="mso-number-format:0\.0000;">1.4498</td><td style="mso-number-format:0\.0000;">1.4296</td><td class=msdate nowrap>2009.12.17 20:53</td><td style="mso-number-format:0\.0000;">1.4343</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>1.23</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#61 ">4607402</td><td class=msdate nowrap>2009.12.18 04:23</td><td>sell</td><td class=mspt>0.31</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4401</td><td style="mso-number-format:0\.0000;">1.4443</td><td style="mso-number-format:0\.0000;">1.4351</td><td class=msdate nowrap>2009.12.18 04:48</td><td style="mso-number-format:0\.0000;">1.4391</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.10</td></tr>


<tr align=right>
    <td colspan=10> </td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>-13.31</td>
</tr>

<tr align=right>
    <td colspan=12 align=right><b>Closed P/L:</b></td>
    <td colspan=2 align=right title="Commission + Swap + Profit + Taxes" class=mspt><b>-13.31</b></td>
</tr>

<tr align=left><td colspan=14><b>Open Trades:</b></td></tr>
<tr align=center bgcolor="#C0C0C0">
    <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
    <td>Price</td><td>S / L</td><td>T / P</td><td> </td>
    <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>
<tr align=right><td title="#41 ">4600864</td><td class=msdate nowrap>2009.12.18 01:58</td><td>sell</td><td class=mspt>0.42</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4359</td><td style="mso-number-format:0\.0000;">1.4417</td><td style="mso-number-format:0\.0000;">1.4309</td><td class=msdate nowrap> </td><td style="mso-number-format:0\.0000;">1.4383</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-10.08</td></tr>

 

I need to assign the content

 

Transactions:</b></td></tr>
<tr align=center bgcolor="#C0C0C0">
   <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
   <td>Price</td><td>S / L</td><td>T / P</td><td nowrap>Close Time</td>
   <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>

<tr align=right><td title="DEPOSIT VIA LOCAL DEPOSITOR">4435945</td><td class=msdate nowrap>2009.12.14 00:42</td><td>balance</td><td colspan=10 align=left>DEPOSIT VIA LOCAL DEPOSITOR</td><td class=mspt>100.00</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="WELCOME BONUS">4438265</td><td class=msdate nowrap>2009.12.14 01:49</td><td>balance</td><td colspan=10 align=left>WELCOME BONUS</td><td class=mspt>20.00</td></tr>
<tr align=right><td title="#61 ">4513245</td><td class=msdate nowrap>2009.12.16 03:58</td><td>buy</td><td class=mspt>0.48</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4528</td><td style="mso-number-format:0\.0000;">1.4486</td><td style="mso-number-format:0\.0000;">1.4578</td><td class=msdate nowrap>2009.12.16 05:00</td><td style="mso-number-format:0\.0000;">1.4535</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.36</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#41 [sl]">4549667</td><td class=msdate nowrap>2009.12.17 01:12</td><td>buy</td><td class=mspt>0.50</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4513</td><td style="mso-number-format:0\.0000;">1.4471</td><td style="mso-number-format:0\.0000;">1.4563</td><td class=msdate nowrap>2009.12.17 01:49</td><td style="mso-number-format:0\.0000;">1.4471</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-21.00</td></tr>
<tr align=right><td title="#21 ">4591750</td><td class=msdate nowrap>2009.12.17 19:16</td><td>sell</td><td class=mspt>0.41</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4346</td><td style="mso-number-format:0\.0000;">1.4498</td><td style="mso-number-format:0\.0000;">1.4296</td><td class=msdate nowrap>2009.12.17 20:53</td><td style="mso-number-format:0\.0000;">1.4343</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>1.23</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#61 ">4607402</td><td class=msdate nowrap>2009.12.18 04:23</td><td>sell</td><td class=mspt>0.31</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4401</td><td style="mso-number-format:0\.0000;">1.4443</td><td style="mso-number-format:0\.0000;">1.4351</td><td class=msdate nowrap>2009.12.18 04:48</td><td style="mso-number-format:0\.0000;">1.4391</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.10</td></tr>


<tr align=right>
    <td colspan=10> </td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>-13.31</td>
</tr>
<tr align=right>
    <td colspan=12 align=right><b>Closed

 

to a new variable $transac_info.

 

I'd tried this

$ffetch = //"the above code";

if(preg_match('/(Transactions:)(.*?)(Closed)/s', $ffetch, $matches));

 

but it doesn't work. I'm new to regex, is it any error to my code?

Please help :) thanks

Link to comment
Share on other sites

$input = <<<html
<tr align=left><td colspan=14><b>Closed Transactions:</b></td></tr>
<tr align=center bgcolor="#C0C0C0">
   <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
   <td>Price</td><td>S / L</td><td>T / P</td><td nowrap>Close Time</td>
   <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>
<tr align=right><td title="DEPOSIT VIA LOCAL DEPOSITOR">4435945</td><td class=msdate nowrap>2009.12.14 00:42</td><td>balance</td><td colspan=10 align=left>DEPOSIT VIA LOCAL DEPOSITOR</td><td class=mspt>100.00</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="WELCOME BONUS">4438265</td><td class=msdate nowrap>2009.12.14 01:49</td><td>balance</td><td colspan=10 align=left>WELCOME BONUS</td><td class=mspt>20.00</td></tr>
<tr align=right><td title="#61 ">4513245</td><td class=msdate nowrap>2009.12.16 03:58</td><td>buy</td><td class=mspt>0.48</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4528</td><td style="mso-number-format:0\.0000;">1.4486</td><td style="mso-number-format:0\.0000;">1.4578</td><td class=msdate nowrap>2009.12.16 05:00</td><td style="mso-number-format:0\.0000;">1.4535</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.36</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#41 [sl]">4549667</td><td class=msdate nowrap>2009.12.17 01:12</td><td>buy</td><td class=mspt>0.50</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4513</td><td style="mso-number-format:0\.0000;">1.4471</td><td style="mso-number-format:0\.0000;">1.4563</td><td class=msdate nowrap>2009.12.17 01:49</td><td style="mso-number-format:0\.0000;">1.4471</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-21.00</td></tr>
<tr align=right><td title="#21 ">4591750</td><td class=msdate nowrap>2009.12.17 19:16</td><td>sell</td><td class=mspt>0.41</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4346</td><td style="mso-number-format:0\.0000;">1.4498</td><td style="mso-number-format:0\.0000;">1.4296</td><td class=msdate nowrap>2009.12.17 20:53</td><td style="mso-number-format:0\.0000;">1.4343</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>1.23</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#61 ">4607402</td><td class=msdate nowrap>2009.12.18 04:23</td><td>sell</td><td class=mspt>0.31</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4401</td><td style="mso-number-format:0\.0000;">1.4443</td><td style="mso-number-format:0\.0000;">1.4351</td><td class=msdate nowrap>2009.12.18 04:48</td><td style="mso-number-format:0\.0000;">1.4391</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.10</td></tr>


<tr align=right>
    <td colspan=10> </td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>-13.31</td>
</tr>

<tr align=right>
    <td colspan=12 align=right><b>Closed P/L:</b></td>
    <td colspan=2 align=right title="Commission + Swap + Profit + Taxes" class=mspt><b>-13.31</b></td>
</tr>

<tr align=left><td colspan=14><b>Open Trades:</b></td></tr>
<tr align=center bgcolor="#C0C0C0">
    <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
    <td>Price</td><td>S / L</td><td>T / P</td><td> </td>
    <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>
<tr align=right><td title="#41 ">4600864</td><td class=msdate nowrap>2009.12.18 01:58</td><td>sell</td><td class=mspt>0.42</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4359</td><td style="mso-number-format:0\.0000;">1.4417</td><td style="mso-number-format:0\.0000;">1.4309</td><td class=msdate nowrap> </td><td style="mso-number-format:0\.0000;">1.4383</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-10.08</td></tr>
html;

preg_match('/(Transactions:)(.*?)(Closed)/s', $input, $matches);

 

Gives the output...

 

Array
(
    [0] => Transactions:</b></td></tr>
<tr align=center bgcolor="#C0C0C0">
   <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
   <td>Price</td><td>S / L</td><td>T / P</td><td nowrap>Close Time</td>
   <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>
<tr align=right><td title="DEPOSIT VIA LOCAL DEPOSITOR">4435945</td><td class=msdate nowrap>2009.12.14 00:42</td><td>balance</td><td colspan=10 align=left>DEPOSIT VIA LOCAL DEPOSITOR</td><td class=mspt>100.00</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="WELCOME BONUS">4438265</td><td class=msdate nowrap>2009.12.14 01:49</td><td>balance</td><td colspan=10 align=left>WELCOME BONUS</td><td class=mspt>20.00</td></tr>
<tr align=right><td title="#61 ">4513245</td><td class=msdate nowrap>2009.12.16 03:58</td><td>buy</td><td class=mspt>0.48</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4528</td><td style="mso-number-format:0\.0000;">1.4486</td><td style="mso-number-format:0\.0000;">1.4578</td><td class=msdate nowrap>2009.12.16 05:00</td><td style="mso-number-format:0\.0000;">1.4535</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.36</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#41 [sl]">4549667</td><td class=msdate nowrap>2009.12.17 01:12</td><td>buy</td><td class=mspt>0.50</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4513</td><td style="mso-number-format:0\.0000;">1.4471</td><td style="mso-number-format:0\.0000;">1.4563</td><td class=msdate nowrap>2009.12.17 01:49</td><td style="mso-number-format:0\.0000;">1.4471</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-21.00</td></tr>
<tr align=right><td title="#21 ">4591750</td><td class=msdate nowrap>2009.12.17 19:16</td><td>sell</td><td class=mspt>0.41</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4346</td><td style="mso-number-format:0\.0000;">1.4498</td><td style="mso-number-format:0\.0000;">1.4296</td><td class=msdate nowrap>2009.12.17 20:53</td><td style="mso-number-format:0\.0000;">1.4343</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>1.23</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#61 ">4607402</td><td class=msdate nowrap>2009.12.18 04:23</td><td>sell</td><td class=mspt>0.31</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4401</td><td style="mso-number-format:0\.0000;">1.4443</td><td style="mso-number-format:0\.0000;">1.4351</td><td class=msdate nowrap>2009.12.18 04:48</td><td style="mso-number-format:0\.0000;">1.4391</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.10</td></tr>

<tr align=right>
    <td colspan=10> </td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>-13.31</td>
</tr>

<tr align=right>
    <td colspan=12 align=right><b>Closed
    [1] => Transactions:
    [2] => </b></td></tr>
<tr align=center bgcolor="#C0C0C0">
   <td>Ticket</td><td nowrap>Open Time</td><td>Type</td><td>Size</td><td>Item</td>
   <td>Price</td><td>S / L</td><td>T / P</td><td nowrap>Close Time</td>
   <td>Price</td><td>Commission</td><td>Taxes</td><td>Swap</td><td>Profit</td></tr>
<tr align=right><td title="DEPOSIT VIA LOCAL DEPOSITOR">4435945</td><td class=msdate nowrap>2009.12.14 00:42</td><td>balance</td><td colspan=10 align=left>DEPOSIT VIA LOCAL DEPOSITOR</td><td class=mspt>100.00</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="WELCOME BONUS">4438265</td><td class=msdate nowrap>2009.12.14 01:49</td><td>balance</td><td colspan=10 align=left>WELCOME BONUS</td><td class=mspt>20.00</td></tr>
<tr align=right><td title="#61 ">4513245</td><td class=msdate nowrap>2009.12.16 03:58</td><td>buy</td><td class=mspt>0.48</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4528</td><td style="mso-number-format:0\.0000;">1.4486</td><td style="mso-number-format:0\.0000;">1.4578</td><td class=msdate nowrap>2009.12.16 05:00</td><td style="mso-number-format:0\.0000;">1.4535</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.36</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#41 [sl]">4549667</td><td class=msdate nowrap>2009.12.17 01:12</td><td>buy</td><td class=mspt>0.50</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4513</td><td style="mso-number-format:0\.0000;">1.4471</td><td style="mso-number-format:0\.0000;">1.4563</td><td class=msdate nowrap>2009.12.17 01:49</td><td style="mso-number-format:0\.0000;">1.4471</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>-21.00</td></tr>
<tr align=right><td title="#21 ">4591750</td><td class=msdate nowrap>2009.12.17 19:16</td><td>sell</td><td class=mspt>0.41</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4346</td><td style="mso-number-format:0\.0000;">1.4498</td><td style="mso-number-format:0\.0000;">1.4296</td><td class=msdate nowrap>2009.12.17 20:53</td><td style="mso-number-format:0\.0000;">1.4343</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>1.23</td></tr>
<tr bgcolor=#E0E0E0 align=right><td title="#61 ">4607402</td><td class=msdate nowrap>2009.12.18 04:23</td><td>sell</td><td class=mspt>0.31</td><td>eurusd</td><td style="mso-number-format:0\.0000;">1.4401</td><td style="mso-number-format:0\.0000;">1.4443</td><td style="mso-number-format:0\.0000;">1.4351</td><td class=msdate nowrap>2009.12.18 04:48</td><td style="mso-number-format:0\.0000;">1.4391</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>0.00</td><td class=mspt>3.10</td></tr>

<tr align=right>
    <td colspan=10> </td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>0.00</td>
    <td class=mspt>-13.31</td>
</tr>

<tr align=right>
    <td colspan=12 align=right><b>
    [3] => Closed
)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.