-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparser.php
67 lines (53 loc) · 1.34 KB
/
parser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
function nettix_parse_meta($item) {
set_time_limit(180);
$xml = simplexml_load_file($item);
$meta = json_decode(json_encode((array)$xml),1);
// save nettix URL in meta fields
unset($meta[0]);
$meta['source'] = $item;
// get nettix ID
$meta['nettixID'] = (string)$xml->id;
// get item title
$meta['title'] = (string)$xml->make .' '. (string)$xml->model .' '. (string)$xml->year;
$images = array();
for($x=0;$x<count($meta['media']['image']);$x++){
$images[] = $meta['media']['image'][$x]['imgUrl'];
}
unset($meta['media']['image']);
/*foreach( $meta['image'] as $element ) {
$images[]=$element['imgUrl'];
}*/
$meta['images'] = $images;
return $meta;
}
/**
* Fetch the dealer list
*/
function nettix_get_links(){
$nettix_url = '';
$xml = simplexml_load_file($nettix_url);
$items = array();
foreach( $xml->children() as $child){
$items[] = $child->adListUrl;
}
return $items;
}
/**
* Parse links for each individual ad
*/
function nettix_parse_links($directory) {
$xml = simplexml_load_file($directory);
$items = array();
foreach( $xml->children() as $child){
$items[] = $child->adUrl;
}
return $items;
}
$dealers = nettix_get_links();
foreach( $dealers as $link ){
$links = nettix_parse_links($link);
foreach($links as $ad){
print_r(nettix_parse_meta($ad));
}
}