Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,690 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,310 people online right now. Registration is fast and FREE... Join Now!




PHP + XML

 
Reply to this topicStart new topic

PHP + XML, How do I process it?

spearfish
post 30 May, 2008 - 03:53 PM
Post #1


Monkey in Training

Group Icon
Joined: 10 Mar, 2008
Posts: 746



Thanked 2 times

Dream Kudos: 225
My Contributions


Hi guys,

I've got the basics of PHP down, now I'm into the more difficult stuff. How do I parse XML? Right now, I'm working on a modification for Simple Machines Forums that will block registration if an IP or Email address is that of a known spambot.

Essentially, I need to find a way to get the information from this URL:
http://www.stopforumspam.com/api?ip=91.186.18.61
(Just an example IP)

Which outputs this XML:
xml

<response success="true">
<type>ip</type>
<appears>yes</appears>
<lastseen>2008-05-14 15:59:55</lastseen>
<frequency>9</frequency>
</response>


Then, I need to check if "appears" is set to "yes".

How would I go about doing this in PHP?
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 30 May, 2008 - 08:58 PM
Post #2


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 596



Thanked 22 times

Dream Kudos: 750
My Contributions


QUOTE(spearfish @ 30 May, 2008 - 04:53 PM) *

Hi guys,

I've got the basics of PHP down, now I'm into the more difficult stuff. How do I parse XML? Right now, I'm working on a modification for Simple Machines Forums that will block registration if an IP or Email address is that of a known spambot.

Essentially, I need to find a way to get the information from this URL:
http://www.stopforumspam.com/api?ip=91.186.18.61
(Just an example IP)

Which outputs this XML:
xml

<response success="true">
<type>ip</type>
<appears>yes</appears>
<lastseen>2008-05-14 15:59:55</lastseen>
<frequency>9</frequency>
</response>


Then, I need to check if "appears" is set to "yes".

How would I go about doing this in PHP?


You would have to create a new parser object and use the various parsing functions to get to your 'appears' node. There's a great tutorial on beginning parsing here. Also, for a complete list of the xml parsing functions in php you can visit php.net's page here.

Let me know if you need some more help after reading those.
User is offlineProfile CardPM

Go to the top of the page

spearfish
post 31 May, 2008 - 05:41 AM
Post #3


Monkey in Training

Group Icon
Joined: 10 Mar, 2008
Posts: 746



Thanked 2 times

Dream Kudos: 225
My Contributions


Thanks!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:38AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month