Skip to content

DOMDocument throwing empty source validation error #29

@zainavrillo534102

Description

@zainavrillo534102

I have an issue today where i was trying to fetch an xml data from soap API. When i tried to use that data and tried to convert it using XML wrangler getting below error . I event tried to validate the xml through the custom DOMDocument class usage and it shows its valid and okay.

function isValidXml($xml): bool
    {
        libxml_use_internal_errors(true);
        $doc = new \DOMDocument();
        $isValid = $doc->loadXML($xml);
        if (!$isValid) {
            $errors = libxml_get_errors();
            foreach ($errors as $error) {
                Log::error('XML Error: ' . $error->message);
            }
            libxml_clear_errors();
        }
        return $isValid;
    }

alueError: DOMDocument::loadXML(): Argument #1 ($source) must not be empty in /home/forge/proclaim.avrillo.co.uk/vendor/veewee/xml/src/Xml/Dom/Loader/xml_string_loader.php:18
--
Stack trace:
#0 /home/forge/proclaim.avrillo.co.uk/vendor/veewee/xml/src/Xml/Dom/Loader/xml_string_loader.php(18): DOMDocument->loadXML()
#1 /home/forge/proclaim.avrillo.co.uk/vendor/veewee/xml/src/Xml/Dom/Loader/load.php(20): VeeWee\Xml\Dom\Loader\{closure}()
#2 /home/forge/proclaim.avrillo.co.uk/vendor/azjezz/psl/src/Psl/Result/wrap.php(23): VeeWee\Xml\Dom\Loader\{closure}()

To Reproduce

  1. Due to senitivity i can't give the xml here as it contains the attachment base64 but when i used this package with the same incoming xml it does not gave any error
    This was my code snippet
 return XmlReader::fromString($this->xmlData)->removeNamespaces()->values();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions