-2
I need to read the XML below. How I access the information?
<?php
$arq = '<?xml version="1.0" standalone="yes"?>
<ans:mensagemTISS xmlns:ans="http://www.ans.gov.br/padroes/tiss/schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ans.gov.br/padroes/tiss/schemas http://www.ans.gov.br/padroes/tiss/schemas/tissV3_02_00.xsd">
<ans:cabecalho>
<ans:identificacaoTransacao>
<ans:tipoTransacao>ENVIO_LOTE_GUIAS</ans:tipoTransacao>
<ans:dataRegistroTransacao>2014-12-22</ans:dataRegistroTransacao>
<ans:horaRegistroTransacao>11:15:01</ans:horaRegistroTransacao>
</ans:identificacaoTransacao>';
$sxe = new SimpleXMLElement($arq);
$namespaces = $sxe->getNamespaces(true);
var_dump($namespaces);
?>
I have this error return:
Warning: SimpleXMLElement::__construct(): Entity: line 8: parser error : Premature end of data in tag cabecalho line 3 in C:\xampp\htdocs\test\index.php on line 12
Warning: SimpleXMLElement::__construct(): </ans:identificacaoTransacao> in C:\xampp\htdocs\test\index.php on line 12
Warning: SimpleXMLElement::__construct(): ^ in C:\xampp\htdocs\test\index.php on line 12
Warning: SimpleXMLElement::__construct(): Entity: line 8: parser error : Premature end of data in tag mensagemTISS line 2 in C:\xampp\htdocs\test\index.php on line 12
Warning: SimpleXMLElement::__construct(): </ans:identificacaoTransacao> in C:\xampp\htdocs\test\index.php on line 12
Warning: SimpleXMLElement::__construct(): ^ in C:\xampp\htdocs\test\index.php on line 12
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\test\index.php:12 Stack trace: #0 C:\xampp\htdocs\test\index.php(12): SimpleXMLElement->__construct('<?xml version="...') #1 {main} thrown in C:\xampp\htdocs\test\index.php on line 12
Thank you, you gave it right. This is what I needed. Thank you
– user152855