RSS XML feed uitlezen, namespaces?
Het stuk XML
Code (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
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
<item>
<title>Hengelo - Heerde, Hengelo Uitgebrande BMW aangetroffen</title>
<description>Het overvallenteam Twente onderzoekt of een in Heerde aangetroffen, uitgebrande BMW betrokken was bij de woningoverval in Hengelo O.</description>
<category>nieuwsbericht</category>
<pubDate>Thu, 06 Nov 2014 11:00:00 GMT</pubDate>
<dc:date>2014-11-06T11:00:00Z</dc:date>
<content:items>
<rdf:Bag>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea kop">
<rdf:value><![CDATA[Opsporing Verzocht]]></rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea kop">
<rdf:value><![CDATA[Getuigen gezocht]]></rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea kop">
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Categorie">
<rdf:value><![CDATA[Brand]]></rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Categorie">
<rdf:value><![CDATA[Overval]]></rdf:value>
</content:item>
</rdf:li>
</rdf:Bag>
</content:items>
<geo:lat>52.271158</geo:lat>
<geo:long>6.793925700000045</geo:long>
</item>
<title>Hengelo - Heerde, Hengelo Uitgebrande BMW aangetroffen</title>
<description>Het overvallenteam Twente onderzoekt of een in Heerde aangetroffen, uitgebrande BMW betrokken was bij de woningoverval in Hengelo O.</description>
<category>nieuwsbericht</category>
<pubDate>Thu, 06 Nov 2014 11:00:00 GMT</pubDate>
<dc:date>2014-11-06T11:00:00Z</dc:date>
<content:items>
<rdf:Bag>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea kop">
<rdf:value><![CDATA[Opsporing Verzocht]]></rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea kop">
<rdf:value><![CDATA[Getuigen gezocht]]></rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea kop">
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Alinea">
<content:format rdf:resource="http://www.w3.org/TR/html4/" />
<rdf:value>Tekst</rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Categorie">
<rdf:value><![CDATA[Brand]]></rdf:value>
</content:item>
</rdf:li>
<rdf:li>
<content:item rdf:about="Categorie">
<rdf:value><![CDATA[Overval]]></rdf:value>
</content:item>
</rdf:li>
</rdf:Bag>
</content:items>
<geo:lat>52.271158</geo:lat>
<geo:long>6.793925700000045</geo:long>
</item>
Tot nu heb ik:
Code (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
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
<?php
foreach($xml->channel->item as $item)
{
$namespaces = $item->getNameSpaces(true);
$titel = mysql_real_escape_string($item->title);
$pla = explode(' - ',trim($titel));
$plaats = str_replace('(Ov)', '', $pla[0]);
if($pla[1] == 'Gezocht'){ $titel = $pla[2]; }else{ $titel = $pla[1]; }
$datum = $item->children($namespaces['dc'])->date;
$datumtekens = array('T', 'Z');
$datum = str_replace($datumtekens, ' ', $datum);
$beschrijving = mysql_real_escape_string($item->description);
//$item->registerXPathNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
//$tekst = $item->xpath('//content:items');
$getabout = $item->children($namespaces['rdf'])->about;
$about = $item->children($namespaces['content'])->items->children($namespaces['rdf'])->Bag->children($namespaces['rdf'])->li->children($namespaces['content'])->item['rdf:about'];
// Deze werkt
$alinea = $item->children($namespaces['content'])->items->children($namespaces['rdf'])->Bag->children($namespaces['rdf'])->li->children($namespaces['content'])->item->children($namespaces['rdf'])->value;
$lat = $item->children($namespaces['geo'])->lat;
$long = $item->children($namespaces['geo'])->long;
echo 'Titel: '.$titel.'<br />';
echo 'Plaats: '.$plaats.'<br />';
echo 'Datum: '.$datum.'<br />';
echo 'Beschrijving: '.$beschrijving.'<br />';
echo 'Geo lat: '.$lat.'<br />';
echo 'Geo long: '.$long.'<br />';
echo 'About: '.$about.'<br />';
echo 'Content: '.$alinea.'<br />';
echo '<br />';
if($hoogstedatum == '0')//Geen datum alles toevoegen
{
//
}
elseif($datum > $hoogstedatum )// Aleen nieuwe datums toevoegen
{
//
}
}
?>
foreach($xml->channel->item as $item)
{
$namespaces = $item->getNameSpaces(true);
$titel = mysql_real_escape_string($item->title);
$pla = explode(' - ',trim($titel));
$plaats = str_replace('(Ov)', '', $pla[0]);
if($pla[1] == 'Gezocht'){ $titel = $pla[2]; }else{ $titel = $pla[1]; }
$datum = $item->children($namespaces['dc'])->date;
$datumtekens = array('T', 'Z');
$datum = str_replace($datumtekens, ' ', $datum);
$beschrijving = mysql_real_escape_string($item->description);
//$item->registerXPathNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
//$tekst = $item->xpath('//content:items');
$getabout = $item->children($namespaces['rdf'])->about;
$about = $item->children($namespaces['content'])->items->children($namespaces['rdf'])->Bag->children($namespaces['rdf'])->li->children($namespaces['content'])->item['rdf:about'];
// Deze werkt
$alinea = $item->children($namespaces['content'])->items->children($namespaces['rdf'])->Bag->children($namespaces['rdf'])->li->children($namespaces['content'])->item->children($namespaces['rdf'])->value;
$lat = $item->children($namespaces['geo'])->lat;
$long = $item->children($namespaces['geo'])->long;
echo 'Titel: '.$titel.'<br />';
echo 'Plaats: '.$plaats.'<br />';
echo 'Datum: '.$datum.'<br />';
echo 'Beschrijving: '.$beschrijving.'<br />';
echo 'Geo lat: '.$lat.'<br />';
echo 'Geo long: '.$long.'<br />';
echo 'About: '.$about.'<br />';
echo 'Content: '.$alinea.'<br />';
echo '<br />';
if($hoogstedatum == '0')//Geen datum alles toevoegen
{
//
}
elseif($datum > $hoogstedatum )// Aleen nieuwe datums toevoegen
{
//
}
}
?>
Toevoeging op 12/11/2014 17:42:49:
Iemand?
Gewijzigd op 12/11/2014 17:41:58 door Ferdi R
Gewijzigd op 13/11/2014 21:50:48 door Ferdi R