Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-23-2011, 08:34 AM   #1
CS-Jay
Confirmed User
 
CS-Jay's Avatar
 
Join Date: Oct 2003
Location: Command Central, West Palm Beach, Fl
Posts: 1,794
PHP and xml help!

I'm a bit stuck and hope someone can lend a hand. I cannot get the value of, Choice, using simplexml.

Here's the xml:

PHP Code:
<Choice ID="1000">
<
Select NAME="BOB/>
Monday
</Choice>
<Choice ID="
1001">
<Select NAME="
Mary/>
Tuesday
</Choice
I am looping through, trying to get the value of Choice, but I get the array of Select. I would like just get the days.

PHP Code:
$arr = array();
foreach (
$Choice AS $choice){
$arr[] = $choice;
}
print_r($arr); 
Any ideas?
__________________
I do stuff - aIm CS_Jay_D

Last edited by CS-Jay; 02-23-2011 at 08:36 AM..
CS-Jay is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-23-2011, 09:00 AM   #2
potter
Confirmed User
 
Industry Role:
Join Date: Dec 2004
Location: Denver
Posts: 6,559
You're going to want an XML parser to parse the XML into an array.

http://php.net/manual/en/function.xml-parse.php

http://php.net/manual/en/function.xm...nto-struct.php
__________________

potter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-23-2011, 09:07 AM   #3
CS-Jay
Confirmed User
 
CS-Jay's Avatar
 
Join Date: Oct 2003
Location: Command Central, West Palm Beach, Fl
Posts: 1,794
Quote:
Originally Posted by potter View Post
You're going to want an XML parser to parse the XML into an array.

http://php.net/manual/en/function.xml-parse.php

http://php.net/manual/en/function.xm...nto-struct.php
I guess I should stop resisting using anything else than simplexml.
__________________
I do stuff - aIm CS_Jay_D
CS-Jay is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-23-2011, 09:33 AM   #4
HarryMuff
Confirmed User
 
HarryMuff's Avatar
 
Join Date: Dec 2005
Posts: 271
Use DOM? Don't think you can get the textNode children using simplexml.

Code:
$xml =
'<derp>
    <Choice ID="1000">
        <Select NAME="BOB" />
        Monday
    </Choice>
    <Choice ID="1001">
        <Select NAME="Mary" />
        Tuesday
    </Choice>
</derp>';
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadXML($xml);
foreach($dom->getElementsByTagName('Choice') as $choice)
{
    $arr[] = $choice->textContent;
}
print_r($arr);
HarryMuff is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-23-2011, 10:06 AM   #5
CS-Jay
Confirmed User
 
CS-Jay's Avatar
 
Join Date: Oct 2003
Location: Command Central, West Palm Beach, Fl
Posts: 1,794
Quote:
Originally Posted by HarryMuff View Post
Use DOM? Don't think you can get the textNode children using simplexml.

Code:
$xml =
'<derp>
    <Choice ID="1000">
        <Select NAME="BOB" />
        Monday
    </Choice>
    <Choice ID="1001">
        <Select NAME="Mary" />
        Tuesday
    </Choice>
</derp>';
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadXML($xml);
foreach($dom->getElementsByTagName('Choice') as $choice)
{
    $arr[] = $choice->textContent;
}
print_r($arr);
Off to give DOM a try
__________________
I do stuff - aIm CS_Jay_D
CS-Jay is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.