Jump to content



Photo

[PHP] XML Parsing Script

php xml

  • Please log in to reply
7 replies to this topic

#1 phate

phate

    INTP

  • Joined: 23-December 04
  • Location: Tempe Arizona

Posted 10 February 2012 - 15:55

For anyone that might have experienced this problem before, I'm trying to import my Wordpress feed into a website using a PHP XML parsing script... well that is the intention. I've Googled to try and find something that is relevant to my interests but to no avail, most of the scripts I've found don't particularly deliver what I need. I was hoping for something that pulls in the title of the latest post, the featured image and x amount of characters from the start of the post, all of it posted in html with customisable tags.

I'm not the most skilled PHP programmer (still learning), and I've spent hours trying to get it to work so this is a last resort really. Any help would be greatly appreciated.


#2 Laser

Laser

    Neowinian

  • Joined: 21-March 03

Posted 10 February 2012 - 16:02

Hope this will help you it is a tut I used to figure out how to parse a feed for my site.

http://www.kirupa.co...ntermediate.htm

#3 OP phate

phate

    INTP

  • Joined: 23-December 04
  • Location: Tempe Arizona

Posted 10 February 2012 - 16:13

I've tried the beginners script, it worked but not to the full functionality that I needed, got stuck with the intermediate one. It just wouldn't open my feed at all! I downloaded the feed saved it as xml_intermediate.xml it just output the html at the end of the script.

#4 OP phate

phate

    INTP

  • Joined: 23-December 04
  • Location: Tempe Arizona

Posted 10 February 2012 - 16:23

fyi
http://www.smoothfin....co.uk/sandbox/
http://www.smoothfin...ntermediate.xml
http://www.smoothfin...co.uk/index.txt

#5 Laser

Laser

    Neowinian

  • Joined: 21-March 03

Posted 10 February 2012 - 17:49

can you post the code your using from the intermediate tut thats not working.

#6 HeyRatFans

HeyRatFans

    [This space for rent]

  • Joined: 04-November 01

Posted 10 February 2012 - 21:01

If you want to make XML with PHP really, really easy, forget using XML Parser and use SimpleXML instead.

#7 Boz

Boz

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 21-October 03

Posted 10 February 2012 - 21:08

If you want to make XML with PHP really, really easy, forget using XML Parser and use SimpleXML instead.


Another vote for SimpleXML.

#8 OP phate

phate

    INTP

  • Joined: 23-December 04
  • Location: Tempe Arizona

Posted 14 February 2012 - 10:00

for anyone that is interested I ended up solving this using this persons contribution http://www.corvidwor...-on-other-pages

really clever and simple, I recommend it if anyone finds themselves needing this kind of solution


		  <?php
		  // Include WordPress
		  define('WP_USE_THEMES', false);
		  require('../blog/wp-load.php');
		  query_posts('showposts=1');
		  ?>
		  <?php while (have_posts()): the_post(); ?>

		  <?php endwhile; ?>
		  <?php while (have_posts()): the_post(); ?>
		  <h2><?php the_title(); ?></h2>
		  <?php the_excerpt(); ?>
		  <p><a href="<?php the_permalink(); ?>">Read more...</a></p>
		  <img src="<?php featured_image(); ?>">
		  <?php endwhile; ?>




Click here to login or here to register to remove this ad, it's free!