PHPDaemon\XMLStream\XMLStream::startXML PHP Method

startXML() public method

XML start callback
See also: xml_set_element_handler
public startXML ( resource $parser, string $name, array $attr ) : void
$parser resource
$name string
$attr array
return void
    public function startXML($parser, $name, $attr)
    {
        ++$this->xml_depth;
        if (array_key_exists('XMLNS', $attr)) {
            $this->current_ns[$this->xml_depth] = $attr['XMLNS'];
        } else {
            $this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
            if (!$this->current_ns[$this->xml_depth]) {
                $this->current_ns[$this->xml_depth] = $this->default_ns;
            }
        }
        $ns = $this->current_ns[$this->xml_depth];
        foreach ($attr as $key => $value) {
            if (mb_orig_strpos($key, ':') !== false) {
                $key = explode(':', $key);
                $key = $key[1];
                $this->ns_map[$key] = $value;
            }
        }
        if (mb_orig_strpos($name, ':') !== false) {
            $name = explode(':', $name);
            $ns = $this->ns_map[$name[0]];
            $name = $name[1];
        }
        $obj = new XMLStreamObject($name, $ns, $attr);
        if ($this->xml_depth > 1) {
            $this->xmlobj[$this->xml_depth - 1]->subs[] = $obj;
        }
        $this->xmlobj[$this->xml_depth] = $obj;
    }