带有<m:properties> </m:properties>的simplexml_load_file

时间:2014-02-19 08:03:17

标签: php xml simplexml

我正在尝试从XML文件中获取内容,但它并没有真正返回所有内容。以下是XML网址:

XML Example

提取物:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="https://api.datamarket.azure.com/Data.ashx/opendata.rdw/VRTG.Open.Data/v1/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">KENT_VRTG_O_DAT</title>
  <id>https://api.datamarket.azure.com/Data.ashx/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT</id>
  <updated>2014-02-19T08:05:16Z</updated>
  <link rel="self" title="KENT_VRTG_O_DAT" href="KENT_VRTG_O_DAT" />
  <entry>
    <id>https://api.datamarket.azure.com/Data.ashx/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT('0001ES')</id>
    <title type="text"></title>
    <updated>2014-02-19T08:05:16Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="KENT_VRTG_O_DAT" href="KENT_VRTG_O_DAT('0001ES')" />
    <category term="opendata.rdw.VRTG.Open.Data.KENT_VRTG_O_DAT" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Aantalcilinders m:type="Edm.Int16">4</d:Aantalcilinders>
        <d:Aantalstaanplaatsen m:type="Edm.Int16" m:null="true" />
        <d:Aantalzitplaatsen m:type="Edm.Int16" m:null="true" />
        <d:BPM m:type="Edm.Int32" m:null="true" />

您可以在entry->content下看到,<m:properties>内有我需要的所有信息。但是,当我print_r内容时,[content]部分就是这样:

 SimpleXMLElement Object
(
[@attributes] => Array
    (
        [type] => application/xml
    )

)

我做错了什么?

提前致谢。

修改

我已经检查过以前的答案,但我似乎找不到任何适合我的方法。这是我正在使用的代码:

$data->entry->content->m->children('d', true)->Aantalcilinders

解决方案

 $data->entry->content->children('m', true)->children('d', true)->Aantalcilinders 

0 个答案:

没有答案