PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.21
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.21
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
fluent-booking / vendor / wpfluent / caldav / src / ICal / XmlParser.php

XmlParser.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.5.21, at vendor/wpfluent/caldav/src/ICal/XmlParser.php

67 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\Package\CalDav\ICal;
4
5 use DOMDocument;
6 use DOMXPath;
7
8 class XmlParser
9 {
10 public static function parse($xml)
11 {
12 $instance = new static;
13
14 $doc = new DOMDocument();
15
16 $doc->loadXML($xml);
17
18 $xpath = new DOMXPath($doc);
19
20 $xpath->registerNamespace('d', 'DAV:');
21
22 $list = [];
23
24 foreach ($xpath->query('//d:response') as $res) {
25 $list[] = $instance->parseNodes($res);
26 }
27
28 return $list;
29 }
30
31 protected function parseNodes($x)
32 {
33 $nodes = [];
34
35 foreach ($x->childNodes as $n) {
36 if ($this->hasChild($n)) {
37 $nodes[$n->localName][] = $this->parseNodes($n);
38 } else if ($n->nodeType == XML_ELEMENT_NODE) {
39 $nodes[$n->localName][] = $n->nodeValue;
40
41 if ($n->hasAttributes()) {
42 foreach ($n->attributes as $attr) {
43 $nodes[$n->localName][]['attributers'][$attr->nodeName] = $attr->nodeValue;
44 }
45
46 $nodes[$n->localName] = array_values(array_filter($nodes[$n->localName]));
47 }
48 }
49 }
50
51 return $nodes;
52 }
53
54 protected function hasChild($n)
55 {
56 if ($n->hasChildNodes()) {
57 foreach ($n->childNodes as $c) {
58 if ($c->nodeType == XML_ELEMENT_NODE) {
59 return true;
60 }
61 }
62 }
63
64 return false;
65 }
66 }
67