XML parsing using simpleXML

scabs

New Member
I am trying to parse the XML found on the page ...http://www.rapleaf.com/apidoc/person\[code\]Name: Test DummyAge: 42gender: MaleAddress: San Francisco, CA, USOccupation:University: Berkeleyfirst seen: 2006-02-23last seen: 2008-09-25Friends: 42Name:Age:gender:Address:Occupation:University:first seen:last seen:Friends: \[/code\]1) I had to remove the records where "&" was found. I could process the page only after that.2) I could not parse the "membership site" nor could I parse "occupation"3) I am getting 2 records when I am expecting only one.4) How do I insert these records in the Database?\[code\]<?php// displays all the file nodesif(!$xml=simplexml_load_file('rapleaf.xml')){ trigger_error('Error reading XML file',E_USER_ERROR);}foreach($xml as $user){ echo 'Name: '.$user->name. '<br /> Age: '.$user->age.'<br /> gender: '.$user->gender.'<br /> Address: '.$user->location.'<br /> Occupation: '.$user->occupations->occupation->company.'<br /> University: '.$user->universities->university.'<br /> first seen: '.$user->earliest_known_activity.'<br /> last seen: '.$user->latest_known_activity.'<br /> Friends: '.$user->num_friends.'<br />';}?>\[/code\]
 
Back
Top