javifelices icon

Obtener datos de un xml

javifelices | PRO | 03/21/19 09:08:43 AM UTC | 0 ⭐ | 242 👁️ | Never ⏰ | []
PHP |

640 B

|

None

|

0 👍

/

0 👎

$postdata = http_build_query(
    array(
        'numg' => $numG,
        'nump' => $numP,
        'password' => $pass
    )
);
 
$opts = array(
    'ssl' =>
    array(
        'verify_peer' => false,
        'verify_peer_name' => false,
    ),
    'http' =>
    array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);
 
$context = stream_context_create($opts);
$contents = file_get_contents($url, false, $context);
 
$xml = simplexml_load_string(html_entity_decode($contents));
if ($xml === false) {
    echo "Error cargando XML\n";
    foreach (libxml_get_errors() as $error) {
        echo "\t", $error->message;
    }
}

Comments