How do I get RAW XML from this script?

1

I am using this script that sends information to a server, and it responds with XML. The result is passed to another script using a variable. How do I get raw XML, without filtering it?

function lafuncion($dato1,$dato2)
{
$this->connect("La direccion");
		//get the output
		$xmlstr=$this->getOutput();
		if($xmlstr=='')
		{
			$this->errors[]='No output.';
			return false;
		}
		//disconnect
		$this->disconnect();

		//get the output xml as an array using simple xml
		$xml = new SimpleXMLElement($xmlstr);

		if($xml->result->status==1)
		{
			
			$result['status']=$xml->result->status;
			$result['statusmsg']=$xml->result->statusmsg;
			$result['ip']=$xml->result->options->ip;
			return $result;
		}
		else
		{
			$this->errors[]=$xml->result->statusmsg;
			return false;
		}
	}
    
asked by Mike 06.01.2018 в 20:49
source

1 answer

0

You can use the asXML() method to get a string :

$xml = new SimpleXMLElement($xmlstr);
$string = $xml->asXML();

Personally I like to use the class DOMDocument instead of SimpleXML :

$doc = new DOMDocument();
$doc->loadXML($xmlstr);
$string = $doc->saveXML();
    
answered by 08.01.2018 / 20:24
source