My knowledge in php isn't the most promising, so I would like to ask if anyone could help me out with this.

This is what I get back when running print_r($xml) where $xml = simplexml_load_file('http://api.test.org/xml/?lalala123);

SimpleXMLElement Object ( 
	[apikey] => asd2defdf164asdseasd06535fasdf0a 
	[uid] => 1110333 
	[language] => en 
	[users] => SimpleXMLElement Object ( 
		[user] => SimpleXMLElement Object ( 
			[@attributes] => Array ( 
				[uid] => 1110333 
			) 
			[name] => bull 
			[surname] => torres 
			[nick] => SimpleXMLElement Object ( ) 
			[place] => SimpleXMLElement Object ( ) 
			[img] => http://xx.xx/xx.jpg 
			[sex] => M 
			[birthday] => SimpleXMLElement Object ( ) 
			[age] => SimpleXMLElement Object ( ) 
			[adult] => 1 
			[type] => User_Default 
			[deleted] => SimpleXMLElement Object ( ) 
		) 
	) 
)

And Im trying to assign all of the info to different variables so that I can use them in my code.

So far I've work out a way to get apikey wich looks like this:
echo $xml->apikey;

But I cant find a way to get things like name, surname and so on.

Anyone knows a way to do that? Thanks in advance.🙂

    It's not [font=monospace]$xml->users->user->name[/font], etc?

    And Im trying to assign all of the info to different variables so that I can use them in my code.

    Incidentally, can't you just leave them where they are and refer to them as [font=monospace]$xml->apikey[/font], etc? Or do you want to organise them differently from how they're organised here? What I'm getting at is that having your data well organised makes everything else much simpler.

      Hell yeah $name = $xml->users->user->name is working!! Thanks a lot, Weedpacket!

      Actually, the way it looks now, I'm only gonna use these to run a mysql insert and save those bits that I need.

      I was thinking to do it this way:

      			$query = sprintf("INSERT INTO members (`name`, `surname`, `uid`) VALUES ('%s', '%s', '%d')",
      						mysql_real_escape_string($name),
      						mysql_real_escape_string($surname),
      						mysql_real_escape_string($uid),
      						);
      			if (!mysql_query($query)) die();

      But will try and see if mysql_real_escape_string($xml->users->user->name) works.

      Thanks again, Weedpacket.

        Write a Reply...