Ben aşağıda formatında bazı xml veri var -
<xyz:reqResponse
xmlns:xyz="http://www.test.com/xyz/"
xmlns:akt="http://www.exmple.com/akt/">
<xyz:version>1.2</xyz:version>
<xyz:totalRecords>659</xyz:totalRecords>
<xyz:records>
<xyz:record>
<doc>
<str name="icon_url">http://www.icons.net/icon1.jpg</str>
<str name="type">Service</str>
<arr name="bc.recordTitle"><str>Evergreen Club</str></arr>
<str name="bc.id">KLM0078</str>
<str name="system.external.id">787678</str>
<arr name="bc.description">
<str>Meetings: Church Hall Beaudesert Lane. Open to anyone over 50.</str>
</arr>
<str name="code">X1209</str>
<double name="localval1">-4.00006</double>
<double name="localval2">-7.00012</double>
<date name="timestamp">Wed Jun 02 21:19:33 BST 2010</date>
</doc>
</xyz:record>
<xyz:record>
<doc>
<str name="icon_url">http://www.icons.net/icon1.jpg</str>
<str name="type">Service</str>
<arr name="bc.recordTitle"><str>Evergreen Club</str></arr>
<str name="bc.id">KLM0078</str>
<str name="system.external.id">787678</str>
<arr name="bc.description">
<str>Meetings: Church Hall Beaudesert Lane. Open to anyone over 50.</str>
</arr>
<str name="code">X1209</str>
<double name="localval1">-4.00006</double>
<double name="localval2">-7.00012</double>
<date name="timestamp">Wed Jun 02 21:19:33 BST 2010</date>
</doc>
</xyz:record>
</xyz:records>
</xyz:reqResponse>
Ben böyle bir şey yapmak
$xml = simplexml_load_string($xml_data);
$namespaces = $xml->getNameSpaces(true);
$data = $xml->children($namespaces['xyz']);
eğer öyleyse ben baskı
echo $data->totalRecords; //outputs correctly 659
Ben tüm kayıtları döngü çalışıyor ve bireysel erişim alanlar ancak bunu nasıl hiçbir ipucu var duyuyorum.
Ben böyle bir şey denedim
$records = $data->records;
foreach($records as $record) {
echo print_r($record, true);
}
ama çok yararlı oldu.
My questions are -
- how to access each <xyz:record>
and its sub items (which are <str name="abc">NAbc</str>
etc?
With thanks, Kay