| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
XML Serializer - Bug #13896: Bad info in the RSS feed tutorial
|
|
|
3 |
--FILE--
|
|
|
4 |
<?php
|
|
|
5 |
|
|
|
6 |
require_once 'XML/Serializer.php';
|
|
|
7 |
|
|
|
8 |
$options = array(
|
|
|
9 |
"indent" => " ",
|
|
|
10 |
"linebreak" => "\n",
|
|
|
11 |
"typeHints" => false,
|
|
|
12 |
"addDecl" => true,
|
|
|
13 |
"encoding" => "UTF-8",
|
|
|
14 |
"rootName" => "rdf:RDF",
|
|
|
15 |
"defaultTagName" => "item"
|
|
|
16 |
);
|
|
|
17 |
|
|
|
18 |
$stories[] = array(
|
|
|
19 |
'title' => 'First Article',
|
|
|
20 |
'link' => 'http://freedomink.org/node/view/55',
|
|
|
21 |
'description' => 'Short blurb about article........'
|
|
|
22 |
);
|
|
|
23 |
$stories[] = array(
|
|
|
24 |
'title' => 'Second Article',
|
|
|
25 |
'link' => 'http://freedomink.org/node/view/11',
|
|
|
26 |
'description' => 'This article shows you how ......'
|
|
|
27 |
);
|
|
|
28 |
|
|
|
29 |
$data['channel'] = array(
|
|
|
30 |
"title" => "Freedom Ink",
|
|
|
31 |
"link" => "http://freedomink.org/",
|
|
|
32 |
$stories
|
|
|
33 |
);
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* might later considering rewriting it
|
|
|
38 |
* to show the option setting this way
|
|
|
39 |
$ser= new XML_Serializer();
|
|
|
40 |
$ser->setOption(XML_SERIALIZER_OPTION_INDENT, ' ');
|
|
|
41 |
$ser->setOption(XML_SERIALIZER_OPTION_XML_DECL_ENABLED, true);
|
|
|
42 |
$ser->setOption(XML_SERIALIZER_OPTION_XML_ENCODING, 'UTF-8');
|
|
|
43 |
$ser->setOption(XML_SERIALIZER_OPTION_ROOT_NAME, 'rdf:RDF');
|
|
|
44 |
$ser->setOption(XML_SERIALIZER_OPTION_DEFAULT_TAG, 'item');
|
|
|
45 |
**/
|
|
|
46 |
|
|
|
47 |
$ser = new XML_Serializer($options);
|
|
|
48 |
if ($ser->serialize($data)) {
|
|
|
49 |
header('Content-type: text/xml');
|
|
|
50 |
echo $ser->getSerializedData();
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
?>
|
|
|
54 |
--EXPECT--
|
|
|
55 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
56 |
<rdf:RDF>
|
|
|
57 |
<channel>
|
|
|
58 |
<title>Freedom Ink</title>
|
|
|
59 |
<link>http://freedomink.org/</link>
|
|
|
60 |
<item>
|
|
|
61 |
<item>
|
|
|
62 |
<title>First Article</title>
|
|
|
63 |
<link>http://freedomink.org/node/view/55</link>
|
|
|
64 |
<description>Short blurb about article........</description>
|
|
|
65 |
</item>
|
|
|
66 |
<item>
|
|
|
67 |
<title>Second Article</title>
|
|
|
68 |
<link>http://freedomink.org/node/view/11</link>
|
|
|
69 |
<description>This article shows you how ......</description>
|
|
|
70 |
</item>
|
|
|
71 |
</item>
|
|
|
72 |
</channel>
|
|
|
73 |
</rdf:RDF>
|