2012-07-07 17 views

回答

0
<?php 

$content = '<abc> 
      <ls:location> 
        <ls:address1>No 16 GLama</ls:address1> 
        <ls:city>Kuala Lumpur</ls:city> 
        <ls:zip>58200</ls:zip> 
        <ls:latitude>3.092055</ls:latitude> 
        <ls:longitude>101.684757</ls:longitude> 
      </ls:location> 
      </abc>'; 


$x = new SimpleXmlElement($content); 

// accessing the wanted value in the object 
// returns zip as an object 
$zip = $x->location->zip; 

// object to string type conversion 
$zip = (string) $zip; 

assert('$zip == "58200" /* Expected result: zip = 58200. */'); 
?>