Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #11326

Re: Load Data from XML url

From Fiver <numeralfive@gmail.com>
Newsgroups comp.lang.php
Subject Re: Load Data from XML url
Date 2013-10-09 22:23 +0200
Organization A noiseless patient Spider
Message-ID <l34e08$6gn$1@dont-email.me> (permalink)
References <63b3437b-f172-453d-a143-390c32599e1f@googlegroups.com> <slrnl57qss.kov.hellsop@nibelheim.ninehells.com> <fc2b5bd2-b86d-4d6d-ad14-2f3acd4b601a@googlegroups.com>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Load Data from XML url frank.catry@gmail.com - 2013-10-08 01:00 -0700
  Re: Load Data from XML url "Peter H. Coffin" <hellsop@ninehells.com> - 2013-10-08 06:25 -0500
    Re: Load Data from XML url Frank Catry <frank.catry@gmail.com> - 2013-10-09 12:51 -0700
      Re: Load Data from XML url Fiver <numeralfive@gmail.com> - 2013-10-09 22:23 +0200
        Re: Load Data from XML url Frank Catry <frank.catry@gmail.com> - 2013-10-10 00:38 -0700
          Re: Load Data from XML url Fiver <numeralfive@gmail.com> - 2013-10-12 06:17 +0200
  Re: Load Data from XML url Frank Catry <frank.catry@gmail.com> - 2013-10-13 09:16 -0700
    Re: Load Data from XML url Arno Welzel <usenet@arnowelzel.de> - 2013-10-20 16:08 +0200

csiph-web