I am trying to get content from a XML file, but it's not really returning everything. Here is the XML url for example:
Extract:
<?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" />
You can see under entry->content
, there is a <m:properties>
with inside all information I need. However, when I print_r
the contents the [content]
part is just this:
SimpleXMLElement Object
(
[@attributes] => Array
(
[type] => application/xml
)
)
What am I doing wrong?
Thanks in advance.
EDIT
I have checked the previous answers, but I cant seem to find anything that works for me. This is the code I am using:
$data->entry->content->m->children('d', true)->Aantalcilinders
Solution
$data->entry->content->children('m', true)->children('d', true)->Aantalcilinders