The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP-General - Grab HTML from Source code pasted into Text Field
Discuss Grab HTML from Source code pasted into Text Field in the PHP Development forum on Dev Shed. Grab HTML from Source code pasted into Text Field PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 14th, 2009, 01:18 AM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 12
Time spent in forums: 3 h 52 m 32 sec
Reputation Power: 0
|
|
|
PHP-General - Grab HTML from Source code pasted into Text Field
I am tring to make a page that will grab html data from source code that a user paste into a text field. Problem is, all the examples I see are for grabbing data from url's or sites instead of just source code.
Can anyone point me in the direction to find out how on earth to make this work. If you have some sample code it would help a lot.
I basically need to pull the HTML from the source and strip away all the java script and excess tags.
thanks
|

January 14th, 2009, 01:35 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|

January 14th, 2009, 11:30 PM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 12
Time spent in forums: 3 h 52 m 32 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by requinix |
I am not trying to strip the tags out of the source code, I am trying to get the basic HTML code that contains some data and a table.
This is the source code.
Code:
<HTML><HEAD><TITLE>Alliance Game</TITLE>
<style type="text/css">
BODY, TABLE {font-family: verdana,arial; font-size: 13px}
INPUT, SELECT {font-family: verdana,arial; font-size: 11px}
.small {font-size: 12px}
.xsmall {font-size: 11px}
.gray {color: #b0b0b0}
.black {color: #000000}
.title {color: #ffeecc; background: #400000; font: bold}
.bluetitle {color: #ffeecc; background: #000040; font: bold}
.y {color: #ffeecc; font: bold}
</style>
<script language="JavaScript" type="text/javascript" src="ads/ad_interstitial.js"></script>
</HEAD>
<BODY BGCOLOR=#000000 TEXT=#FFFFFE LINK=#FFEECC VLINK=#FFDDBB
>
<CENTER>
<P><table width=100%><tr align=center valign=top><td>
<script language=Javascript>swid=1;</script>
<script type="text/javascript" src="ads/ad_top.js"></script><P><TABLE CELLSPACING=5><TR bgcolor=#000040><TD>Turns: 10</TD><TD>Money: $238,681,220</TD><TD>Food: 2,165,120 Bushels</TD><TD>Networth: $18,143,148</TD><TR></TABLE>
The status of the <B>Republic</B> of <B>Canyon Land (#750)</B>.<P>
<TABLE><TR ALIGN=CENTER VALIGN=TOP><TD>
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>The Basics</TH></TR>
<TR><TD>Turns Left</TD><TD ALIGN=RIGHT>10</TD></TR>
<TR><TD>Turns Taken</TD><TD ALIGN=RIGHT>2938</TD></TR>
<TR><TD>Turns Stored</TD><TD ALIGN=RIGHT>0</TD></TR>
<TR><TD>Rank</TD><TD ALIGN=RIGHT>38</TD></TR>
<TR><TD>Networth</TD><TD ALIGN=RIGHT>$18,143,148</TD></TR>
</TABLE></TD><TD WIDTH=25> </TD><TD>
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>Current Status</TH></TR>
<TR><TD>Money</TD><TD ALIGN=RIGHT>$238,681,220</TD></TR>
<TR><TD>Population</TD><TD ALIGN=RIGHT>501,921</TD></TR>
<TR><TD>Land</TD><TD ALIGN=RIGHT>18865 Acres</TD></TR>
<TR><TD>Food</TD><TD ALIGN=RIGHT>2,165,120 bushels</TD></TR>
<TR class=small><TD> Production</TD><TD ALIGN=RIGHT>7 bushels</TD></TR>
<TR class=small><TD> Consumption</TD><TD ALIGN=RIGHT>23,525 bushels</TD></TR>
<TR class=small><TD> Net Change</TD><TD ALIGN=RIGHT>-23,518 bushels</TD></TR>
<TR><TD>Oil</TD><TD ALIGN=RIGHT>1,140,920 barrels</TD></TR>
</TABLE></TD><TD WIDTH=25> </TD><TD>
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>Economics</TH></TR>
<TR><TD>Tax Revenues</TD><TD ALIGN=RIGHT>$10,375,953</TD></TR>
<TR class=small><TD> Tax Rate</TD><TD ALIGN=RIGHT>35%</TD></TR>
<TR class=small><TD> Per Capita Income</TD><TD ALIGN=RIGHT>$59.06</TD></TR>
<TR><TD>Expenses</TD><TD ALIGN=RIGHT>$4,419,146</TD></TR>
<TR class=small><TD> Military</TD><TD ALIGN=RIGHT>$4,112,567</TD></TR>
<TR class=small><TD> Alliance/GDI</TD><TD ALIGN=RIGHT>$117,929</TD></TR>
<TR class=small><TD> Land</TD><TD ALIGN=RIGHT>$188,650</TD></TR>
<TR><TD>Net Income</TD><TD ALIGN=RIGHT>$5,956,807</TD></TR>
</TABLE><BR></TD></TR>
<TR><TD COLSPAN=5><CENTER><P><U>Advisor Notes</U></CENTER><BR><B>Food Concern</B>: We are currently experiencing a food shortage. Assuming no growth, we can survive for <B>92</B> turns.<P>
<B>Foreign Affairs</B>: If you have not already considered joining
the GDI, we recommend you look into it. While you'll have to weigh
the costs and benefits, the GDI can protect us from powerful countries
looking to seize our territories!<P>
<BR></td></tr>
<TR ALIGN=CENTER VALIGN=TOP><TD>
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>Land Distribution</TH></TR>
<TR><TD>Enterprise Zones</TD><TD align=right>8663</td></tr><TR><TD>Residences</TD><TD align=right>8663</td></tr><TR><TD>Industrial Complexes</TD><TD align=right>260</td></tr><TR><TD>Military Bases</TD><TD align=right>960</td></tr><TR><TD>Research Labs</TD><TD align=right>0</td></tr><TR><TD>Farms</TD><TD align=right>0</td></tr><TR><TD>Oil Rigs</TD><TD align=right>0</td></tr><TR><TD>Construction Sites</TD><TD align=right>300</td></tr><TR><TD>Unused Lands</TD><TD align=right>19</td></tr></TABLE></TD><TD WIDTH=25> </TD><TD>
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>Military Forces</TH></TR>
<TR><TD>Spies</TD><TD align=right>218,990</TD></TR><TR><TD>Troops</TD><TD align=right>4,807,197</TD></TR><TR><TD>Jets</TD><TD align=right>9,142,002</TD></TR><TR><TD>Turrets</TD><TD align=right>4,348,609</TD></TR><TR><TD>Tanks</TD><TD align=right>1,328,015</TD></TR><TR><TD>Nuclear Missiles</TD><TD align=right>5</TD></TR><TR><TD>Chemical Missiles</TD><TD align=right>12</TD></TR><TR><TD>Cruise Missiles</TD><TD align=right>9</TD></TR></TABLE></TD><TD WIDTH=25> </TD><TD>
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>Technology</TH></TR>
<TR><TD>Military</TD><TD align=right>288,889</TD></TR><TR><TD>Medical</TD><TD align=right>18,716</TD></TR><TR><TD>Business</TD><TD align=right>508,812</TD></TR><TR><TD>Residential</TD><TD align=right>509,326</TD></TR><TR><TD>Agricultural</TD><TD align=right>2316</TD></TR><TR><TD>Warfare</TD><TD align=right>2931</TD></TR><TR><TD>Military Strategy</TD><TD align=right>9334</TD></TR><TR><TD>Weapons</TD><TD align=right>827</TD></TR><TR><TD>Industrial</TD><TD align=right>8651</TD></TR><TR><TD>Spy</TD><TD align=right>3587</TD></TR><TR><TD>SDI</TD><TD align=right>190,345</TD></TR></TABLE></TD></TR>
</TABLE>
<BR><BR>
</td><script language=Javascript>swid=1;</script>
<td width=120 align=right><script type="text/javascript" src="ads/ad_side.js"></script></td></tr></table></BODY></HTML>
Basically I want everything from
Code:
The status of the <B>Republic</B> of <B>Canyon Land (#750)</B>.<P>
To
Code:
<TR><TD>Net Income</TD><TD ALIGN=RIGHT>$5,956,807</TD></TR>
and
Code:
<TABLE>
<TR><TH COLSPAN=2 BGCOLOR=#000040>Land Distribution</TH></TR>
to
Code:
<TR><TD>SDI</TD><TD align=right>190,345</TD></TR></TABLE></TD></TR>
</TABLE>
I need to get rid of everything else
strip_tags only gets rid of all the html tags from the code.
Thanks for the reply, and I hope this will help a little more
|

January 14th, 2009, 11:50 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Use a regular expression, it's really simple.
Ask your question again here and you can get more help.
|

January 15th, 2009, 02:31 AM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 12
Time spent in forums: 3 h 52 m 32 sec
Reputation Power: 0
|
|
|
posted over there and linked to this thread
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|