Can PHP Parsing Xml Code ?
I am looking for a programming script to parse a xml file. Can PHP do it. The xml file is from other web site and i need to parse it into my html page.
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
BB Code Parsing
how would I go about coding a vBulletin style BBcode parsing engine? eg. to translate [ b] something [ /b] into <b>something</b> etc I know i need todo regular expression searches on the strings, however im a reg-exp newb and really need some guidance. Alternatively, are there any free premade classes etc I could us?
View Replies !
View Related
PHP Not Parsing This Code?
I'm trying to populate an array (with some strange characters). The problem I'm having is the page will ether come up blank, but show the code in the "page source". Or, some or all of the source is sent directly to the browser, like PHP didn't even parse it. I've tried this on a few different servers and get similar, though slightly different results. Here are some examples of what I'm trying to store: Code:
View Replies !
View Related
Help My Slow Parsing Code!
Here's my situation...I've been learning to write PHP for awhile and have been trying to rewrite my web site from plain old static pages to PHP versions. I've been learning based on what I want to do, put my links and articles in databases and allow comments and ratings. I have a test page here: URL I've managed to write the PHP code to do just about everything I wanted, but it takes about 3+ seconds for the page to start to load (and it didn't when it was a static page). I know that this is because of my badly formed PHP no doubt. The routines do what I want, but there HAS to be a much more efficient way to get it done. I'm going to post the code (stipped of font tags and error catching statements). Please advise the easiest way to streamline this code (and or SQL statements) in the best interest of the server processing time (any help would be great!): <?php //Start of routine for animation links $usr = "user"; $pwd = "pw"; $db = "db"; $host = "host"; $cid = mysql_connect($host,$usr,$pwd); ?> <?php //We want the Animated Gif category $category = "1"; $SQL = " SELECT * FROM links_temp"; $SQL = $SQL . " WHERE category = '$category'"; $retid = mysql_db_query($db, $SQL, $cid); //Throw the links in an array - html table loop print ("<center><table cellpadding=2 cellspacing=0 width=100% border=1> "); while ($row = mysql_fetch_array($retid)) { $siteurl = $row["siteurl"]; $sitename = $row["sitename"]; $description = $row["description"]; //cocatenate together anigif_ with each item id for unique rating value $id = "anigif_"; $id = $id . $row["id"]; print ("<tr><td width=100% valign=top>"); //Lets start the form here for the voting to elimate a line break later print ("<form method="POST" action="/test/rating4.php" onsubmit="return genwin()" target="newwin"> "); print ("<A HREF='$siteurl' target=_blank>$sitename</A>"); //While in the while loop lets start another db connection to get item ratings $usr3 = "user"; $pwd3 = "pw"; $db3 = "db"; $host3 = "host"; $cid3 = mysql_connect($host3,$usr3,$pwd3); $SQL3 = " SELECT * FROM ratings_temp WHERE item = "$id""; $result3 = mysql_db_query($db3,"$SQL3",$cid3); $num_rows = mysql_num_rows( $result3 ); if ($num_rows==0) { echo ("No Votes yet"); } else { print " $num_rows Votes, "; $SQL4 = "SELECT AVG(value) AS avgRating FROM ratings_temp WHERE item = "$id""; $result4 = mysql_db_query($db3,"$SQL4",$cid3); print "Rating: " . mysql_result($result4,0) . "<br>"; } mysql_close($cid3); //end of the db connection for ratings print ("$description<br> "); print ("Vote for this Site! "); print (" <select name="rating" size="1"> "); print (" <option value="5" selected>5 - Superb "); print (" <option value="4">4 - Tasty "); print (" <option value="3">3 - Average "); print (" <option value="2">2 - Bland "); print (" <option value="1">1 - Rotten "); print (" </select> "); print (" <input type="hidden" name="item_id" value="$id"> "); print (" <input type="submit" value="Vote"> "); print ("</form> "); print ("</td></tr> "); } //end of the array subroutine making table rows print("</table></center>"); //end of the table after the array ends ?>
View Replies !
View Related
Parsing Vbulletin Code
I've been coding a section where users can post a tutorial and have it show up. I've got the posting down, and I've got the list of tutorials down. I did it by making an invisible forum that it posts to. What I still have to do is use AJAX to make a post clicked on the list show up in the main area, and I have to make it grab the most recent post out of the database and display it. Code:
View Replies !
View Related
Parsing PHP Code In MySQL Results Set?
I have a PHP script that pulls content from an MySQL database and returns a result set. Is there a way I can put PHP code within a field in the database and have that code parsed as PHP code on returning a results set? If possible, I want just one field of the database parsed for PHP code. The results set is return as a straight result, not within a loop. Just inserting the <? PHP code thus ?> returns that as sources code not parsed.
View Replies !
View Related
Parsing String With Embedded PHP Code...
On my webserver right now, I have a folder of webpages with embedded PHP coding. Because the dynamic content changes very infrequently, I've written a script which generates a "static cache" of HTML pages from the PHP pages. It works by automatically looping through all PHP pages in the folder. For each, it reads the contents of the PHP file into a variable, then creates a new HTML page with the same name and writes the contents of the variable to it. After the process is complete, the cache of HTML files gets uploaded to the website for public viewing. However, if the script reads the contents of the PHP pages through the local filesystem, the temporary variable (and thus the resulting static .html page) will have PHP code within it, which is obviously no good. Therefore, at the moment, the script reads the contents of the PHP pages by opening an http connection to where they reside on the public webserver... this makes the contents of the temporary variable equivalent to the HTML that would be outputted when any user accessed the PHP page through the WWW, which is exactly what I want. However... my problem is that the http connections are much slower than reading through the local filesystem, and moreover, I don't necessarily want the PHP pages to be publicly accessible through a webserver, which is currently required for the script to work. Is there any way that I can take a PHP string that has embedded PHP code and tell PHP to "parse the PHP out of it"?
View Replies !
View Related
XML Parsing - Newlines In The Code Disappaers
I have been trying to wrap my head arouns this, but I can't seem to get it to work the way I want it to. Could someone helpful please tell me how I get this: <function> <name>array_push</name> <examples> <example> <name>A way to do it</name> <code> $array = array("foo", "bar") $array = array_push($array, "goo") </code> </example> </examples> </function> To this: array ( name -> array_push examples -> array( example -> array( name -> A way to do it code -> $array = array("foo", "bar") $array = array_push($array, "goo") ) ) ) My problems so far has been traversing the xml in a good way and: 1. After parsing, I am left with the code stripped of variables '$array = array("foo", "bar")' becomes ' = array("foo", "bar")' 2. Newlines in the code disappaers, how do I make them stay? Anyone feeling overly helpful and could give me an example to make the above xml into the above array.
View Replies !
View Related
Parsing PHP Code In An HTML Page!
I am trying to run PHP code from an HTML file. In my HTML file I have the following code: <?php include("<counter/counter.php");?> Now I have read several threads here on Webmaster World, and I have concluded that I need to create a ".htaccess" file, and place the following code in it: AddType application/x-httpd-php .php .htm .html But, once I have done this, every time I visit a page on my site, I get the Open/Save this file dialog. It seems like the server is telling my browser, to open all HTML files with the external application called "application/x-httpd-php". Code:
View Replies !
View Related
Old Code Vs New Code - Language Syntax Change?
I've recently begun programming PHP again and have found my old code doesn't work anymore. It's been a few years since my code was written, and simple functions don't seem to be working. I've done a bit of research into the syntax again and found the following; I used to use a function as such; if ($REQUEST_METHOD=="POST") { Now I've seen alot of the syntax is if ($_SERVER($REQUEST_METHOD=="POST")) { And referencing variables from the form is as such; $_POST['variable'] Where previously I could reference them in the simple form; $variable Has there been a language syntax change that would cause my old code to be obsolete? Is there a configuration line that could be changed to allow this old code to work?
View Replies !
View Related
Regular Expression :: Format Anything Within <code> And </code>
Any regular expression wizards out their tonight? This is driving me crazy...trying to take a string full of HTML and format anything within the <code></code> tags using highlight_string(). $string = "<strong>This</strong> is some HTML!!!<code>echo "Hello, World!";</code>No more code!!!"; $pattern = "(<code>)*(</code>)"; $replacement = " |