Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-15-2007, 12:33 PM   #1 (permalink)
oskare100
Junior Member
 
Join Date: Dec 2006
Posts: 4
Default PHP5 / XML API help!

Hello,
I'm trying to prase and use information I'm getting from an XML API in my system. The user is supposed to be able to choose between the returned agents and then select one of them. When they click "continue" or similar the rows of the agent that the user selected should be saved/assaigned to different PHP variables.

Here is the structure of the XML return:
Code:
<xml> <system> <error> <id>0</id> <message>Your request was successfully processed.</message> 7</error> </system> <response> <service> <name>Agents</name> <version>10</version> </service> <data_list_count>2</data_list_count> </response> <data_list> <data index="0"> <agent_list> <agent index="0"> <name>AGENT & CO IT</name> <address>STREET ADDRESS 2</address> <address2/> <zipcode>500000</zipcode> <city>TOWN</city> <agent_number>0661</agent_number> </agent> <agent index="1"> <name>ANOTHER AGENT</name> <address>STREET ADDRESS 5</address> <address2/> <zipcode>600000</zipcode> <city>CITY</city> <agent_number>0662</agent_number> </agent> </agent_list> </data> </data_list> </xml>

Now I need to list the agents so that the user can select one of them.. I've understood that I should use SimpleXML for this since it is the easiest way.

PHP Code:
$xml simplexml_load_file($request_url) or die("feed not loading"); 


That about what I've managed to do, I understand that in some way I need to list the different agents.

PHP Code:
foreach ($xml-> ...? ) (
print ?



Then I would need to add so that the user can select one of the returned agents and click continue and that my script then can get the rows/information about the selected agent. Maybe HTML POST/GET but I don't know how to make it do that...

I appreciate any help, links, code or whatever I can use to solve this problem.

Thanks
/Oskar
oskare100 is offline   Reply With Quote
Sponsored Links
Old 11-20-2007, 09:13 AM   #2 (permalink)
etono
Moderator
 
Join Date: May 2006
Posts: 86
Default Re: PHP5 / XML API help!

Hello Oskar,

I hope you are not still struggling with this as you posted quite some time ago, but I will go ahead and answer since there were no replies, and maybe someone else may find this useful. You were definitely on the right track. I will finish it up for you:

PHP Code:
$xml simplexml_load_file($request_url) or die("feed not loading");
foreach(
$xml->data_list->data->agent_list->agent as $agent){
print 
$agent->name;

__________________
Jeremy Moseley
My Links: Design Related Blog | Personal Website | Portfolio
etono is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:13 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums