Welcome to WebmasterWorld Guest from 54.167.5.15

Forum Moderators: httpwebwitch

Message Too Old, No Replies

XML Parsing

     

Compworld

6:00 am on Nov 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are a few feeds that I want to use and translate them into banners as special offers on my site. The only problem is that I do not know how to make a XML parser. Is there a program or script that can do this for me?

Mike12345

9:29 am on Nov 16, 2006 (gmt 0)

10+ Year Member



You can probably download a script that will help you, but with xml no tags are predefined, so you will still have to configure it for your feed.

Because XML feeds are so unique I recommend writing your own parser using PHP or Perl. There are basically two ways you can do this:

1) using a tree based parser like MiniXML, this examines the whole xml document and gives you access to it in tree format. This can use up a lot of resources if it is a large feed. But its fine for small feeds, so check out MiniXML on Google.

2) using Expat, this is an event based parser, this uses less resources for larger feeds. It comes built in for PHP, and you can download it for Perl. Look at CPAN for Perl, or PHP.net for PHP versions.

Once the xml is parsed you can do what you want with the data, in your case make it into banners. Are you planning to create images dynamically?

Compworld

11:29 am on Nov 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I wanted to have the banners created dynamically from the XML feed. This is my first time working with XML, so really new to this.

Mike12345

2:09 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



OK, this is do-able, but it can be complicated.

There are a number of ways i can think of doing this.

Both PHP and Perl offer interface to the Gd graphics library which will let you create images on the fly from your scripts.

Depending on your version of PHP it might already be installed, otherwise you will have to get it yourself, same goes for Perl. Check out CPAN for Gd, or PHP.net for details on how to use it. Ive never used it so i cant advise you on exactly how it works.

If you wanted to create animated banners im not sure if Gd will do it, it might. But you could use Ming which is available for PHP and Perl, that might give you more flexabilty for animated stuff as it lets you create flash objects.

I think you will find the XML bit easier. If you give me an example snippet from your XML feed i will see if i can make an example parser for you.

[edited by: Mike12345 at 2:14 pm (utc) on Nov. 16, 2006]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month