Return in XML PHP - Source FORM

Asked

Viewed 82 times

1

I need to give a feedback for 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 am generating XML smoothly 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 hits the address it goes through a redirect so I can get basic functions from the WP platform. The problem is that the result of the form is coming out in HTML and not 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 any questions just ask. THANK YOU!

  • The function that should generate XML is running when vc sends the form? Put the code that should generate the correct response to the browser.

1 answer

0

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

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

More about the function header

Browser other questions tagged

You are not signed in. Login or sign up in order to post.