PHP - Simplexml Sorting Question
I am trying to sort these fields alphabetically by $name - $documents
have run past multiple sort methods but none seem to work. I was hoping someone here knew an easy method to do this xml data: <database> <name>Test</name> <documents>0</documents> <sections>0</sections> </database> <database> <name>Test2</name> <documents>100</documents> <sections>0</sections> </database> current code: <?php $request_url = "http://10.100.100.100:9000/a=getstatus"; $xml = simplexml_load_file($request_url) or die("feed not loading"); echo "<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n"; echo " <tr>\n"; echo " <td>Thor Databases</td>\n"; echo " <td>Count\n"; echo $xml->responsedata->databases->num_databases; echo " </td>\n"; echo " </tr>\n"; foreach ($xml->responsedata->databases->database as $db) { echo"<tr><td>",$db->name,"</td><td>",$db->documents,"</td></tr>\n"; } echo "</table>\n"; ?> Thanks, E Similar TutorialsHello, Hope somebody can help me. I have an XML file that is generated by active directory that dumps everything required for a telephone directory. I currently present this using XSL but would like to move towards PHP. I have some rudimentary code and it's working fine but I'd like to be able to sort by various values, such as First Name or telephone number. My XML format looks like this: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <telephonelist> <employee> <firstname>Jimmy</firstname> <lastname>Jimmerson</lastname> <email>jimbo@companyxyz.com</email> <extensionnum>956</extensionnum> <jobtitle>Security Officer</jobtitle> <department>Security</department> </employee> <employee> <firstname>David</firstname> <lastname>Davidson</lastname> <email>David.Davidson@companyxyz.com</email> <extensionnum>968</extensionnum> <jobtitle>Manager</jobtitle> <department>Management</department> </employee> Any my current code looks like this: Code: [Select] <? $myStaffMembers = new SimpleXMLElement("includes/telephonelist.xml", null, true); echo <<<EOF <table width="95%" border="0"> <tr> <th><b>First Name</b></th> <th><b>Last Name</b></th> <th><b>Telephone Number</b></th> <th><b>Position</b></th> </tr> EOF; foreach($myStaffMembers as $myStaffMember) { echo " <tr> <td>{$myStaffMember->firstname}</td> <td>{$myStaffMember->lastname}</td> <td>{$myStaffMember->extensionnum}</td> <td>{$myStaffMember->jobtitle}</td> </tr>"; } ?> Appreciate any help anybody could give. Thanks, LJ Hello, I am sorry for this question in advance. I will try to explain it as detailed but, as short as possible so bare with me. I have a script that I did that parses an XML file and outputs the info in a table. The tables are created with each entry in XML file. Everything works great and as designed except for when there is no data. I know why it is doing this, I am just not sure how to approach fixing this. So here is what the data looks like where there is nothing and what the table shows. I am posting a screenshot of the XML file as I am not sure it will be empty if I post the link.
So I'm getting a "Notice: Trying to get property of non-object in" error when I'm trying to pull data from a xml. I have a complete xml that has all of the potential node that it could ever have and it loads up fine -no errors, but when I load a different xml that doesn't have all of the possible nodes it returns this error several times here is a sample of my code: $source = 'TestFile.xml'; $xml = new SimpleXMLElement($source,null,true); $result = mysql_query("SELECT * FROM tblvalues") or die(mysql_error()); //Return the table row by row while($row = mysql_fetch_array($result)) { $curblk = substr($row['fldelement'],0,3); switch ($row['fldelement']){ case "E06_04": case "E06_05": case "E06_07": case "E06_08": $cursub = $curblk."_04_0"; $xmlVal = $xml->Header->Record->$curblk->$cursub->$row['fldelement']; //grab value from xml break; ... ... ... // the cases go on for a while... ... case "E07_05": case "E07_06": case "E07_07": case "E07_08": $cursub = $curblk."_03_0"; $cursub2 = $curblk."_05_0"; $xmlVal = $xml->Header->Record->$curblk->$cursub->$cursub2->$row['fldelement']; //this is the line that the error points to break; ... ... ... And here is the sample of the xml that returns the error: Code: [Select] <E07> <E07_01>-20</E07_01> <E07_02>0</E07_02> <E07_15>-25</E07_15> <E07_16>-25</E07_16> <E07_17>-25</E07_17> <E07_18_0> <E07_18_01> <E07_18>-20</E07_18> <E07_19>-20</E07_19> <E07_20>-20</E07_20> </E07_18_01> .... .... .... The obvious problem (to me) is that my code is trying to return a value from a nonexistent xml node, for example: $xmlVal = $xml->Header->Record->$curblk->$cursub->$cursub2->$row['fldelement']; is looking for: $xmlVal = $xml->Header->Record->E07->E07_03_0->E07_05_0->E07_05 Ok, I get that, so how do I rewrite this so it's not blowing up on something so simple? Quick notes: -This same code works for a more complete xml -Rewriting the xmls is not an option as I have no control over those Edit: Almost forgot, thanks! Ok so I have a url that is an XML doc, it says at the top "This XML file does not appear to have any style information associated with it. The document tree is shown below." and it has info like this Code: [Select] <outer> <xml> <viewer> <user> <id>1245789</id> <name>CLueless</user> <business>none</business> </user> </viewer> </xml> </outer> How would I load the link and then assign everything to a variable like id, name and business I usually use something like this but Im trying to get learn simple xml $info = file_get_contents('url'); $id = explode('<id>', $info); $id = explode('</', $id[1]); $name = explode('<name>', $info); $name = explode('</', $name[1]); $biz = explode('<business>', $info); $biz = explode('</', $biz); Hi, I'm new to php and coding in general. I'm trying to parse xml from a remote device and access specific value data. Here is the xml: <?xml version="1.0" encoding="ISO-8859-1" ?> - <Device id="S10011" hb="1935"> <Group id="1" /> <Group id="2" /> <Group id="3" /> <Group id="4" /> <Group id="5" /> <Group id="6" /> <Group id="7" /> <Group id="8" /> - <Group id="9"> - <Probe id="99"> <Value>1.0</Value> </Probe> - <Probe id="1"> <Value>86.4</Value> </Probe> - <Probe id="2"> <Value>45.7</Value> </Probe> - <Probe id="3"> <Value>2.9</Value> </Probe> - <Probe id="4"> <Value>1.0</Value> </Probe> </Group> </Device> ----------------------- Here is my php code to read in the xml: <?php // Establish a port 80 connection $http = fsockopen("192.168.2.106",80); // Send a request to the server $req = "GET /xmldata HTTP/1.0\r\n"; $req .= "Host: 192.168.2.106\r\n"; $req .= "Connection: Close\r\n\r\n"; fputs($http, $req); // Output the request results while(!feof($http)) { $data .= fgets($http, 1024); } // Close the connection fclose($http); $xml = simplexml_load_string($data); print_r ($xml); ?> This yields the following data: SimpleXMLElement Object ( [@attributes] => Array ( [id] => S10011 [hb] => 117546 ) [Group] => Array ( => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 1 ) => ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 2 ) => ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 3 ) => ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 4 ) => ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 5 ) => ) [5] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 6 ) => ) [6] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 7 ) => ) [7] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 8 ) => ) [8] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 9 ) [Probe] => Array ( => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 99 ) [Value] => 1.0 ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 1 ) [Value] => 84.2 ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 2 ) [Value] => 44.1 ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 3 ) [Value] => 4.8 ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 4 ) [Value] => 1.0 ) ) ) ) ) I would like to display group 9 probe 1 value for example and I cannot get it to work. Any tips? so the code is <?php $xml1 = " <outer> <xml> <more_info> <user> <id>200</id> <name>CLUEL3SS</name> </user> <user> <id>201</id> <name>CLUEL3SS2</name> </user> </more_info> </xml> </outer> "; $cwb = simplexml_load_string($xml1); foreach($cwb->xml->more_info->user as $stats) { echo $stats->id."\n";} ?> output is Code: [Select] 200 201 Now, how can I echo the name under <id>201</id> since there is more than one? echo $stats->id."\n"; That echos both of the "ID" values, now how can I get it to only echo the second id 201 and the second name? Thanks Greetings, I am trying to write XML using SimpleXML for a web service call. I was having success until the XML got a little more complicated. Here is the XML format where I am running into problems: Code: [Select] <Agent> <Person Last='Smith' First='John'> <Addresses /> <PhoneNumbers> <Phone Type='1' Number='888-555-1212'> </PhoneNumbers> </Person> </Agent> Here is my php: Code: [Select] $xmlOutput = new SimpleXMLElement('<?xml version="1.0"?><ReportRequest> </ReportRequest>'); $xmlOutput->addAttribute('CID','9200'); $xmlOutput->addAttribute('Diagram','1'); $xmlOutput->addAttribute('DueDate','2011-11-15'); $xmlOutput->addAttribute('NumPhotos','6'); $xmlOutput->addAttribute('InspectAfter',''); $xmlOutput->addAttribute('PolicyNumber','JTC0004425'); $reportType = $xmlOutput->addChild('ReportType'); $reportType->addAttribute('CPType','Commercial'); $reportType->addAttribute('SectionIDs',''); $reportType->addAttribute('Description',''); $reportType->addAttribute('ReportTypeID','123'); $locations = $xmlOutput->addChild('Locations')->addChild('Addresses')->addChild('Address'); $locations->addAttribute('Zip','91216'); $locations->addAttribute('City','Chatsworth'); $locations->addAttribute('Line1','123 Main St'); $locations->addAttribute('Line2','Suite 201'); $locations->addAttribute('State','CA'); $locations->addAttribute('Latitude',''); $locations->addAttribute('Longitude',''); $agent = $xmlOutput->addChild('Agent')->addChild('Person')->addChild('Addresses')->addChild('PhoneNumbers')->addChild('Phone'); $agent->addAttribute('Last','Smith'); $agent->addAttribute('Email',''); $agent->addAttribute('First','John'); $agent->addAttribute('Title',''); $agent->addAttribute('Type','1'); $agent->addAttribute('Number','888-555-1212'); $agent->addAttribute('TypeName','Office'); $agent->addAttribute('Extension',''); Header('Content-type: text/xml'); echo $xmlOutput->asXML(); Everything outputs as it should until the line that starts with $agent. I want the output to match the section above. I have tried several variations but I cannot seem to figure it out. I know the current PHP sample doesn't work. Help?? Thanks in advance, John Hello, I'm trying to read the data of a xml file with the help of simplexml. I'm having trouble reading subchilds. For example im trying to read the following xml: <root> <child> <subchild> <dataineed/> <dataineed/> <dtaineed/> <subchild> </child> </root> I'm using the following code: <?php $oLinkjes = new SimpleXMLElement('http://feedlink.php', 0, TRUE); $countcat = count($oLinkjes->subchild); echo $countcat; ?> It echo's the the result '0' which means that it does not successfully reads the subchild. Because of that i can't get the data i want. When i change subchild to child is does echo '1'. Anyone knows what I'm doing wrong here? I'm new to xml so there might be a easy fix to this. I am trying to find out how to merge the FIPS part of this XML file into one php variable with SimpleXML. a sample xml file I'm trying to use is at http://server1.thezach.net/examplewarn.xml basically i want a variable with "001033,001077" in it (without the quotes) I'm new to PHP and this is my first time using this forum so please forgive me if I'm full of fail I get strings via simplexml with this code $xml = simplexml_load_file("test.xml"); foreach ($xml->title->case as $value){ $param1 = $value->param1; $param2 = $value->param2; Now I want to randomize the xml items (not in their original order); but I cannot use shuffle($value); because it does not consider $value as an array. How can I make a random order? Hey there, I'm having a issue when I edit the XML file from a string here. Now the SimpleXML functions edit the nodes of the XML file perfectly and everything is done the way I want but upon returning the file to a string it keeps putting a XML content type at the top of the file, E.G: Before XML File Is Edited: Code: [Select] <settings> <!-- Port the server will listen on --> <port>7781</port> <!-- Maximum number of players the server will support (Max 32) --> <maxplayers>10</maxplayers> <!-- Maximum number of vehicles the server will support (Max 140) --> <maxvehicles>100</maxvehicles> <!-- Password clients will have to enter to connect --> <!-- password>None</password --> <!-- Add the server to the master list --> <listed>true</listed> <!-- The hostname players will see --> <hostname>IV:MP Server</hostname> <!-- The address the server will bind to --> <!-- hostaddress>127.0.0.1</hostaddress --> <!-- Toggles frequently called events which has impact on CPU usage --> <frequentevents>false</frequentevents> <!-- The scripts the server will load and run --> <script>cp.nut</script> <script>whisper.nut</script> <script>namecheck.nut</script> <script>runcode.nut</script> <!-- The modules the server will load and run --> <!-- For windows: --> <!-- module>Sample.dll</module --> <!-- For linux: --> <!-- module>Sample.so</module --> </settings> After XML File Is Edited Code: [Select] <?xml version=1.0?> <settings> <!-- Port the server will listen on --> <port>7781</port> <!-- Maximum number of players the server will support (Max 32) --> <maxplayers>10</maxplayers> <!-- Maximum number of vehicles the server will support (Max 140) --> <maxvehicles>100</maxvehicles> <!-- Password clients will have to enter to connect --> <!-- password>None</password --> <!-- Add the server to the master list --> <listed>true</listed> <!-- The hostname players will see --> <hostname>IV:MP Server</hostname> <!-- The address the server will bind to --> <!-- hostaddress>127.0.0.1</hostaddress --> <!-- Toggles frequently called events which has impact on CPU usage --> <frequentevents>false</frequentevents> <!-- The scripts the server will load and run --> <script>cp.nut</script> <script>whisper.nut</script> <script>namecheck.nut</script> <script>runcode.nut</script> <!-- The modules the server will load and run --> <!-- For windows: --> <!-- module>Sample.dll</module --> <!-- For linux: --> <!-- module>Sample.so</module --> </settings> Notice the addition to the header of the file "<?xml version=1.0?>". This is causing issues when the XML file is read by the server. Could anybody help me stop the SimpleXML editor from placing this in the header of the file? Thanks. Hi guys! I'm trying to parse an RSS feed using SimpleXML, but I'm having trouble lol Here's my code: $feed = file_get_contents("http://engadget.com/rss.xml"); $xml = new SimpleXMLElement($feed); echo $xml->rss->channel->item[0]->title; I'm expecting it to echo the title of the first item in the RSS feed, but when I run it, I just see a blank page. Tell me what I'm doing wrong! Working with a now playing module for some music. My music player outputs this kind of XML (WHEN THE SONG IS PLAYING): <?xml version="1.0" encoding="utf-8" ?> - <Playing station="Station"> - <item type="MUS"> <Artist>Beatles</Artist> <SongTitle>Get Back</SongTitle> </item> </Playing> My music player outputs this kind of XML (WHEN THE SONG IS NOT PLAYING): <?xml version="1.0" encoding="utf-8" ?> - <Playing station="Station"> - <item type="END"> <Artist>MORE MUSIC SOON</Artist> <SongTitle /> </item> </Playing> Here's my PHP: Code: [Select] <?php $playing = simplexml_load_file("../playlist/nowplaying.xml"); foreach ($playing->item as $item) { printf("Now playing: %s\n", $item->SongTitle); printf("by %s\n", $item->Artist); } ?> I want to make my php document check the item TYPE. (item type="x"). If x equals "MUS", display the PHP like above. But if x displays "END", I want it to display something like "More music coming up". Right now, it displays "MORE MUSIC SOON by " I've attempted if statements to no avail, mainly because I'm not super familiar with them in PHP. Ideas? I am trying to retrieve an attribute from a node and I keep getting the error: Warning: main() [function.main]: Node no longer exists in /Users/dmonsewicz/Projects/noosemonsewicz/api_stuff/index.php on line 70 PHP Code Code: [Select] $xml = new SimpleXMLElement($result); $arr = $xml->tickets->attributes(); echo $arr['count']; XML Code: [Select] <tickets count="0" type="array"></tickets> Any ideas on what I may be doing wrong? Hello, I am using curl with it's code like this: Code: (php) [Select] <?php $urls = 'http://www.a-url.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urls); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "xml=".urlencode($xml_posts)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); $result=curl_exec($ch); var_dump($result); $data = XML_unserialize($result); echo ($data); ?> and using the XML Parse by: Quote # XML Library, by Keith Devens, version 1.2b # http://keithdevens.com/software/phpxml When i echo $data and $result i can see them on the front end and the xml in the source code once i view it. How do i add a SimpleXML to this as i want to get some of the values from the xml file displayed in a array with a number of rows. Does this mean getting rid of the XMLParser function file and using a SimpleXML function file. Can i not use both? When i try to use the SimpleXML functions, i'm clueless in how to get it's data from the xml $results. The XML is the source can be shown like this with me only showing one line: Code: [Select] <Result> <Info> <Details> <Type> <Who> <Name key="1">This is Me</Name> <Number1 key="2">18.93</Number1> <Number2 key="2">20.01</Number2> <Number3 key="2">15.21</Number3> </Who> </Type> </Details> </Info> </Result> Can somebody please help me with this ? I need to getthis sorted !! I have limited idea about SimpleXML but not with the code below and need to edit it so the results can be parsed into a html format. The problem i am having is the XML tags are stored in an existing variable returned from a third party server so need something that can parse this xml info into a html with tags being used. Code: [Select] $xml = "<Inputs>"; $xml.= "<Authentication>"; $xml.= "<Username>$username</Username>"; $xml.= "<Password>$password</Password>"; $xml.= "<RequestType>Term</RequestType>"; $xml.= "<RequestFrom>$system_name</RequestFrom>"; $xml.= "<RequestFromCode>$system_code</RequestFromCode>"; $xml.= "</Authentication>"; $xml.= "<Life1>"; $xml.= "<DOB>$dob</DOB>"; $xml.= "<Sex>$sex</Sex>"; $xml.= "<Smoker>$smoker</Smoker>"; $xml.= "<LifeCover>$lifecover</LifeCover>"; $xml.= "<IllnessCover>N</IllnessCover>"; $xml.= "</Life1>"; $xml.= "<Life2>"; $xml.= "</Life2>"; $xml.= "<Plan>"; $xml.= "<Term>$term</Term>"; $xml.= "<Indexation>N</Indexation>"; $xml.= "<MortgageInterest>6</MortgageInterest>"; $xml.= "<Frequency>Monthly</Frequency>"; $xml.= "<QuoteLifeOnly>Y</QuoteLifeOnly>"; $xml.= "<QuoteLifeAccelerated>$accelerated</QuoteLifeAccelerated>"; $xml.= "<QuoteLifeIllness>N</QuoteLifeIllness>"; $xml.= "<QuoteIllnessOnly>N</QuoteIllnessOnly>"; $xml.= "</Plan>"; $xml.= "</Inputs>"; $url = 'URL NORMALLY HERE'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "xml=".urlencode($xml)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $xml_result=curl_exec($ch); curl_close($ch); print("[$xml_result]"); /* simple xml */ $simplexml = new SimpleXMLElement($xml_result); $Name = $simplexml->Name; echo $Name; /* end */ $data = XML_unserialize($xml_result); $xml_result contains... (with usernames/passwords removed) Code: [Select] <Result> <Errors></Errors> <Inputs><Authentication><Username>####</Username> <Password>####</Password><RequestType>Term</RequestType><RequestFrom>####</RequestFrom><RequestFromCode>####</RequestFromCode></Authentication><Life1><DOB>01/01/1969</DOB><Sex>Male</Sex><Smoker>Non-Smoker</Smoker><LifeCover>100,000</LifeCover><IllnessCover>N</IllnessCover></Life1><Life2></Life2><Plan><Term>10</Term><Indexation>N</Indexation><MortgageInterest>6</MortgageInterest><Frequency>Monthly</Frequency><QuoteLifeOnly>Y</QuoteLifeOnly><QuoteLifeAccelerated>Non-Smoker</QuoteLifeAccelerated><QuoteLifeIllness>N</QuoteLifeIllness><QuoteIllnessOnly>N</QuoteIllnessOnly></Plan></Inputs><Outputs> <Summary> <Life1>Male, 40 years 8 months (01/01/1969), Non-Smoker, life cover 100,000</Life1> <Life2></Life2> <Plan>10 year term, mortgage interest 6.00%, benefits and premiums not increasing.<p>1% levy included.</p></Plan> </Summary> <Quotes> <Type> <Desc>Life Cover Only</Desc> <Company> <Name key="1">Caledonian Life</Name> <PricePledge>False</PricePledge> <Underwriting1></Underwriting1> <SLevel key="2">14.50</SLevel> <SConvertible key="2">15.46</SConvertible> <SMortgage key="2">12.12</SMortgage> </Company> <Company> <Name key="2">Canada Life</Name> <PricePledge>False</PricePledge> <Underwriting1></Underwriting1> <SLevel key="2">15.15</SLevel> <SConvertible key="2">15.91</SConvertible> <SMortgage key="2">13.13</SMortgage> </Company> </Type> </Quotes> </Outputs> </Result> Any advice would be much appreciated I'm pretty new to php. But the below script should get news articles from google news rss. It is failing to load the simplexml and returns false. Any idea why? Code: [Select] $url = "http://news.google.com/news?geo=90210"; if ($xml = @simplexml_load_file($url)) { for ($i=0; $i<4; $i++) { $item= $xml->channel->item[$i]; $link= '<a href = "'.(string) $item->link.'", target= "_blank">'.(string) substr($item->title, 0, 50).'...</a><br />'; $news[]= $link; } } Hi, I don't know why the foreach loop doesn't output the text node content of <toFirstName> and <toLastName>? please see email.xml file below: Code: [Select] <?xml version="1.0" encoding="ISO-8859-1"?> <email> <message> <to> <toFirstName>Tove</toFirstName> <toLastName toType="common" style="swag">Smith</toLastName> </to> <from> <fromFirstName>Jani</fromFirstName> <fromLastName fromType="unique">Dravison</fromLastName> </from> <heading>Reminder</heading> <body> <prologue>Tis the night before Xmas...</prologue> <paragraph1>Don't forget me this weekend!</paragraph1> <paragraph2>Jump the gun!</paragraph2> <epilogue>The end of the world.</epilogue> </body> </message> </email> Please see script below: ================= Code: [Select] <?php $simpleXMLObj=simplexml_load_file("email.xml"); foreach($simpleXMLObj->message[0]->to[0] AS $curDOM) { print $curDOM->toFirstName->getName."<br />".$curDOM->toLastName->getName."<br />"; ?> Please help me out, I would really appreciate it! Hi I want the icon of a digg user $apicall = 'http://services.digg.com/2.0/user.getInfo?usernames='.$username.'&type=xml'; $result = simplexml_load_file($apicall); print_r($result);() With that code I'll get this: Quote SimpleXMLElement Object ( [count] => 1 [users] => SimpleXMLElement Object ( [Ericquits] => SimpleXMLElement Object ( [username] => Ericquits [about] => SimpleXMLElement Object ( ) [user_id] => 20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e [name] => Eric Quit [icons] => SimpleXMLElement Object ( [item] => Array ( => http://cdn3.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/c.4164547322.png [1] => http://cdn1.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/h.4164547322.png [2] => http://cdn3.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/m.4164547322.png [3] => http://cdn3.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/l.4164547322.png [4] => http://cdn1.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/p.4164547322.png [5] => http://cdn3.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/s.4164547322.png [6] => http://cdn3.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/r.4164547322.png ) ) [gender] => SimpleXMLElement Object ( ) [diggs] => 12 [comments] => 1 [followers] => 373 [location] => SimpleXMLElement Object ( ) [following] => 235 [submissions] => 9 [icon] => http://cdn3.diggstatic.com/user/20111010190724:bbd2c60f-17a6-4dc1-8a03-6fd96322752e/p.4164547322.png ) ) [title] => Info for users Ericquits [timestamp] => 1320350425 [uri] => http://services.digg.com/2.0/user.getInfo?usernames=Ericquits&type=json [cursor] => SimpleXMLElement Object ( ) [version] => 2.0 [authorized] => 0 [data] => users [method] => user.getInfo [user] => None So I want the icon the profile image of the user and I make this: print (string)$result->users->Ericquits->icon;() This works, but my question is if there is a solution to get the icon without Ericquits the username? Because if write it little I don't get the icon... |