Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : XmlParser.php
<?php

namespace FluentBooking\Package\CalDav\ICal;

use DOMDocument;
use DOMXPath;

class XmlParser
{
	public static function parse($xml)
	{
		$instance = new static;
		
		$doc = new DOMDocument();

        $doc->loadXML($xml);

        $xpath = new DOMXPath($doc);

        $xpath->registerNamespace('d', 'DAV:');

        $list = [];

        foreach ($xpath->query('//d:response') as $res) {
            $list[] = $instance->parseNodes($res);
        }

        return $list;
	}

	protected function parseNodes($x)
    {
        $nodes = [];

        foreach ($x->childNodes as $n) {
            if ($this->hasChild($n)) {
                $nodes[$n->localName][] = $this->parseNodes($n);
            } else if ($n->nodeType == XML_ELEMENT_NODE) {
                $nodes[$n->localName][] = $n->nodeValue;

                if ($n->hasAttributes()) {
                    foreach ($n->attributes as $attr) {
                        $nodes[$n->localName][]['attributers'][$attr->nodeName] = $attr->nodeValue;
                    }

                    $nodes[$n->localName] = array_values(array_filter($nodes[$n->localName]));
                }
            }
        }

        return $nodes;
    }

    protected function hasChild($n)
    {
        if ($n->hasChildNodes()) {
            foreach ($n->childNodes as $c) {
                if ($c->nodeType == XML_ELEMENT_NODE) {
                    return true;
                }
            }
        }

        return false;
    }
}
© 2026 GrazzMean-Shell