PHP XML Return - FORM Source

1

I need to give a return to this form:

    <form action="http://www.guiabp.com.br/staging/" >
      <input name="chave_portal" value="portalteste-0" />
      <input name="codigo_cliente" value="0" />
      <input name="nome" value="XY" />
      <input name="cnpj_cpf" value="x" />
      <input name="endereco" value="Rua X, 01" />
      <input name="bairro" value="Y" />
      <input name="cidade" value="Z" />
      <input name="uf" value="H" />
      <input name="site" value="www.site.com" />
      <input name="email" value="[email protected]" />
      <input name="fone" value="99 9999.9999" />
      <input name="url_xml" value="http://www.site.com/arquivo.xml" />
    </form>

But the return format is an XML in the format below:

     <?xml version="1.0" encoding="utf-8"?>
     <root>
         <chave_portal>chave-do-portal</chave_portal>
         <codigo_cliente>1</codigo_cliente>
         <status>Ativo</status>
     </root>

I'm generating XML seamlessly using simpleXML:

    $retorno =  new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><root/>');
    $retorno->chave_portal = $_REQUEST['chave_portal'];
    $retorno->codigo_cliente = $user;
    $retorno->status = 'Ativo';

     return $retorno->asXML(INTEGRADOR_DIR.'/vista/xml/registro_'.$user.'_vista.xml');

Let's get to the point. When FORM reaches the address it goes through a redirect so I can pick up basic WP platform functions. The problem is that the result of the form is coming out in HTML rather than in XML. Look at the example below:

     [Content]
     O Resultado da solicitação vinda do Portal não é um arquivo XML válido: 

     <!DOCTYPE html>
     <!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->  
     <!--[if IE 7 ]>    <html class="ie7"> <![endif]-->  
     <!--[if IE 8 ]>    <html class="ie8"> <![endif]-->  
     <!--[if IE 9 ]>    <html class="ie9"> <![endif]--> 
     <!--[if (gt IE 9)|!(IE)]><!--> <html lang="pt-BR"> <!--<![endif]--> 
     <head>
     <title>Guia Bom de Preço | Guia BP | Anúncios Grátis no Guia BP</title>
     <link rel="profile" href="http://gmpg.org/xfn/11" />
     <link rel="pingback" href="http://www.guiabp.com.br/staging/xmlrpc.php" />

If you have questions, just ask. THANK YOU!

    
asked by anonymous 04.04.2017 / 22:46

1 answer

0

I think you want to put the XML header, otherwise PHP returns HTML by default.

header('Content-type: application/xml');

More about the function header

    
05.04.2017 / 02:45