From 04e6c6d4a3a5789c2a065fcfcdb53b65f6e3364a Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Fri, 6 Sep 2024 22:08:02 +0200 Subject: [PATCH] Avoid broken XML-output when no prefix is set --- src/Attribute.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Attribute.php b/src/Attribute.php index 122e1ff..f1144a9 100644 --- a/src/Attribute.php +++ b/src/Attribute.php @@ -108,7 +108,9 @@ public function toXML(DOMElement $parent): DOMElement { $parent->setAttributeNS( $this->getNamespaceURI(), - $this->getNamespacePrefix() . ':' . $this->getAttrName(), + ($this->getNamespacePrefix() !== null) + ? ($this->getNamespacePrefix() . ':' . $this->getAttrName()) + : $this->getAttrName(), $this->getAttrValue(), );