PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 14th, 2009, 01:18 AM
PigeonMarine PigeonMarine is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 12 PigeonMarine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old January 14th, 2009, 01:35 AM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,686 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 3 h 46 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
How about simply using strip_tags?

Reply With Quote
  #3  
Old January 14th, 2009, 11:30 PM
PigeonMarine PigeonMarine is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 12 PigeonMarine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 32 sec
Reputation Power: 0
Quote:
Originally Posted by requinix
How about simply using strip_tags?


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>&nbsp</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>&nbsp;&nbsp;&nbsp;Production</TD><TD ALIGN=RIGHT>7 bushels</TD></TR>
<TR class=small><TD>&nbsp;&nbsp;&nbsp;Consumption</TD><TD ALIGN=RIGHT>23,525 bushels</TD></TR>
<TR class=small><TD>&nbsp;&nbsp;&nbsp;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>&nbsp</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>&nbsp;&nbsp;&nbsp;Tax Rate</TD><TD ALIGN=RIGHT>35%</TD></TR>
<TR class=small><TD>&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;Military</TD><TD ALIGN=RIGHT>$4,112,567</TD></TR>
<TR class=small><TD>&nbsp;&nbsp;&nbsp;Alliance/GDI</TD><TD ALIGN=RIGHT>$117,929</TD></TR>
<TR class=small><TD>&nbsp;&nbsp;&nbsp;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>&nbsp</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>&nbsp</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

Reply With Quote
  #4  
Old January 14th, 2009, 11:50 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,686 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 3 h 46 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Use a regular expression, it's really simple.

Ask your question again here and you can get more help.

Reply With Quote
  #5  
Old January 15th, 2009, 02:31 AM
PigeonMarine PigeonMarine is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 12 PigeonMarine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 32 sec
Reputation Power: 0
posted over there and linked to this thread

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Grab HTML from Source code pasted into Text Field

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap