14 <root xmlns=
"http://sabredav.org/ns">
20 <elem5>foo & bar</elem5>
22 <elem6>Hi<!-- ignore me -->there</elem6>
32 $reader->elementMap = [
33 '{http://sabredav.org/ns}struct' =>
'Sabre\\Xml\\Element\\KeyValue',
40 'name' =>
'{http://sabredav.org/ns}root',
43 'name' =>
'{http://sabredav.org/ns}struct',
45 '{http://sabredav.org/ns}elem1' => null,
46 '{http://sabredav.org/ns}elem2' =>
'hi',
47 '{http://sabredav.org/ns}elem3' => [
49 'name' =>
'{http://sabredav.org/ns}elem4',
54 'name' =>
'{http://sabredav.org/ns}elem5',
55 'value' =>
'foo & bar',
59 '{http://sabredav.org/ns}elem6' =>
'Hithere',
64 'name' =>
'{http://sabredav.org/ns}struct',
69 'name' =>
'{http://sabredav.org/ns}otherThing',
72 'name' =>
'{http://sabredav.org/ns}elem1',
96 <resourcetype><collection /></resourcetype>
97 <displayname>bla</displayname>
105 '{DAV:}set' =>
'Sabre\\Xml\\Element\\KeyValue',
106 '{DAV:}prop' =>
'Sabre\\Xml\\Element\\KeyValue',
107 '{DAV:}resourcetype' =>
'Sabre\\Xml\\Element\\Elements',
112 'name' =>
'{DAV:}mkcol',
115 'name' =>
'{DAV:}set',
118 '{DAV:}resourcetype' => [
121 '{DAV:}displayname' =>
'bla',
130 $this->assertEquals($expected,
$reader->parse());
138 '{http://sabredav.org/ns}elem1' => null,
139 '{http://sabredav.org/ns}elem2' =>
'textValue',
140 '{http://sabredav.org/ns}elem3' => [
141 '{http://sabredav.org/ns}elem4' =>
'text2',
142 '{http://sabredav.org/ns}elem5' => null,
144 '{http://sabredav.org/ns}elem6' =>
'text3',
148 $writer->namespaceMap = [
149 'http://sabredav.org/ns' => null
151 $writer->openMemory();
152 $writer->startDocument(
'1.0');
153 $writer->setIndent(
true);
155 '{http://sabredav.org/ns}root' =>
new KeyValue($value),
158 $output = $writer->outputMemory();
161 <?xml version=
"1.0"?>
162 <root xmlns=
"http://sabredav.org/ns">
164 <elem2>textValue</elem2>
174 $this->assertEquals($expected,
$output);
185 <?xml version=
"1.0" encoding=
"utf-8"?>
186 <root xmlns=
"http://sabredav.org/ns">
187 <elem3>val3</elem3><elem4>val4</elem4><elem5>val5</elem5></root>
192 '{http://sabredav.org/ns}root' =>
'Sabre\\Xml\\Element\\KeyValue',
198 $this->assertEquals([
199 'name' =>
'{http://sabredav.org/ns}root',
201 '{http://sabredav.org/ns}elem3' =>
'val3',
202 '{http://sabredav.org/ns}elem4' =>
'val4',
203 '{http://sabredav.org/ns}elem5' =>
'val5',
testElementEater()
This test was added to find out why an element gets eaten by the SabreDAV MKCOL parser.
testElementSkipProblem()
I discovered that when there's no whitespace between elements, elements can get skipped.
The Reader class expands upon PHP's built-in XMLReader.