FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Load Data from XML url
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Load Data from XML url [message #183115 is a reply to message #183114] Wed, 09 October 2013 20:23 Go to previous messageGo to previous message
Fiver is currently offline  Fiver
Messages: 35
Registered: July 2013
Karma:
Member
On 2013-10-09 21:51, Frank Catry wrote:
> Op dinsdag 8 oktober 2013 13:25:16 UTC+2 schreef Peter H. Coffin:
>> On Tue, 8 Oct 2013 01:00:07 -0700 (PDT), wrote:
>>> how can i load the data from this URL
>>> http://services.mobile.de/1.0.0/refdata/sites/GERMANY/classes/Car/makes
>>> into a array or put them into a table?
>>
>>> I wish to retrieve the values of url, key and local-description.
>>
>> http://php.net/manual/en/function.xml-parse-into-struct.php

> Hi Peter, problem is that the result of this url seems to be NOT XML
> because there are nodes / childs returned. Did you look at the XML ?

Huh? Look at the XML that is not XML?

It's XML alright. Here's something to get you started:

$doc = new DOMDocument();
$doc->load("http://services.mobile.de/ ...yadda...");

$result = [];
$items = $doc->documentElement->getElementsByTagName("item");
foreach ($items as $item) {
$result[] =[
"key" => $item->getAttribute("key"),
"url" => $item->getAttribute("url"),
"description" => $item->textContent,
];
}

print_r($result);

Assumes you can open remote files (i.e. that allow_url_fopen is enabled)
and that the XML namespaces are not important for your task.

regards,
5er
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: glob patterns
Next Topic: how to change character to % character?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 05 14:21:38 GMT 2024

Total time taken to generate the page: 0.04197 seconds