Php 分析<;布尔值></布尔值>;

Php 分析<;布尔值></布尔值>;,php,xml,simplexml,Php,Xml,Simplexml,我想用php解析下面xml中的“true” <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head

我想用php解析下面xml中的“true”

<?xml version="1.0"?> 
<sparql xmlns="http://www.w3.org/2005/sparql-results#"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">

  <head>
    <link href="example2.rq" />
 </head>

  <boolean>true</boolean>

</sparql>

但它不能工作。有没有办法从该xml中获取“true”并将其解析为新变量?

没有,您已经处于父级起点,无需添加sparql:

$result = new SimpleXMLElement($curl_response);
$boolean = $result->boolean;
echo $boolean;

@Kautzar当然很高兴这有帮助
$result = new SimpleXMLElement($curl_response);
$boolean = $result->boolean;
echo $boolean;