shipping
shipping copied to clipboard
Warning: DOMDocument::loadXML(): Empty string supplied as input in vendor/pdt256/shipping/src/USPS/Rate.php on line 166
When the shipping provider's api fails to return a response or returns an empty string, the DOMDocument is throwing a warning and I am unable to catch this in my application.
This becomes a problem when working with XmlHttpRequest as I need to return a JSON format but it becomes invalid as I can't handle the warning thrown by DOMDocument.
Is it possible to fix this so that this code below
https://github.com/pdt256/shipping/blob/190b1d74c9573e66c5359350a70054d84d7436c9/src/USPS/Rate.php#L162-L167
would suppress the $dom->loadXml like
protected function process()
{
try {
$dom = new DOMDocument('1.0', 'UTF-8');
@$dom->loadXml($this->response);
or load $this->response only if it's not empty like
protected function process()
{
try {
$dom = new DOMDocument('1.0', 'UTF-8');
if (empty($this->response)) {
$dom->loadXml('<root></root>');
} else {
$dom->loadXml($this->response);
}
Please let me know if you need more information regarding this issue. I can also do a PR if needed.
Thanks.