Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shedman's avatar

XML URI namespace not absolute

I am trying to implement Authorize.net payment. I was given a script that sends an XML file through CURL. I was getting an error that the namespace is not absolute when creating the doc. I found that I could fix the error by adding HTTP:// to the namespace. However, when I receive the XML doc back it has the namespace without the HTTP:// and so I get an error. I find that most answers to the XML namespace are just a warning, but in Laravel, it is a 500 error. The error is caught at the simplexml_load_string method.

How I address the first error.

<?xml version="1.0" encoding="UTF-8"?>
        <createTransactionRequest xmlns="http://AnetApi/xml/v1/schema/AnetApiSchema.xsd">

The same error is thrown when I receive the XML.

$content = curl_exec($ch);
                if (FALSE === $content)
                    throw new Exception(curl_error($ch), curl_errno($ch));
                curl_close($ch);
                
                $xmlResult=\simplexml_load_string($content);
0 likes
2 replies
kylemilloy's avatar

What are the details of the error thrown by Laravel in the 500? Can you share the full XML that you're sending? If the above is all you're sending you'll need to close the tag:

<createTransactionRequest />
<!-- or -->
<createTransactionRequest></createTransactionRequest>
Shedman's avatar
Shedman
OP
Best Answer
Level 2

The answer is I had to create the XML like this.

$element = new SimpleXMLElement('<createTransactionRequest/>');

$element->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');

Please or to participate in this conversation.