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 #183198 is a reply to message #183132] Sat, 12 October 2013 04:17 Go to previous messageGo to previous message
Fiver is currently offline  Fiver
Messages: 35
Registered: July 2013
Karma:
Member
On 2013-10-10 09:38, Frank Catry wrote:
> Thank you very much. Your script was not working at once so i do
> some changes and get it work in a few minutes.
>
> <?php
> $doc = new DOMDocument();
> $doc->load("http://services.mobile.de/1.0.0/refdata/sites/GERMANY/classes/Car/makes");
>
> $items = $doc->documentElement->getElementsByTagName("item");
>
> foreach ($items as $item) {
> $key=$item->getAttribute("key");
> $description=$item->textContent;
> echo "$key - $description<br>";
> }
>
> die(date('l jS \of F Y h:i:s A'));
> ?>
> Maybe not so professional or fast as your solution but it works for me.
> The values are only to load once a week into a database.

Looking good.

I'm guessing that the reason why my version didn't run for you was this:

$result = [];
..
$result[] = [ ..... ];

That's PHP 5.4 syntax. Sorry, I got used to it so quickly that I keep
forgetting about backward compatibility. In 5.3 you'd write:

$result = array();
..
$result[] = array( ..... );

Everything else should work fine in 5.3, I think.


Ah, one more thing: the "->documentElement" part can be removed, it
doesn't do anything. That was accidentally left in the example while I
was trying something else.


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: Thu Nov 28 17:11:44 GMT 2024

Total time taken to generate the page: 0.03003 seconds