A
A
ArturEvgen1evich2014-10-18 12:15:52
PHP
ArturEvgen1evich, 2014-10-18 12:15:52

How to parse XML with XLS applied to it?

Hello, the task is to parse www.normacs.ru/Doclist The problem is in this line

<?xml-stylesheet type="text/xsl" href="/doclist.xsl"?>

Which converts the document to html. The problem is that the simplexml_load_file function, as well as some others. accept this file exactly as html. That is, a conversion is performed before receiving. How can I get the file in the original xml format, as we see it when we press ctrl+u?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Borisovich, 2014-10-18
@ArturEvgen1evich

<? header('Content-type: text');
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'http://www.normacs.ru/Doclist/');
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_NOBODY, 0); // remove body
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0',
  ));
  $head = curl_exec($ch);
  echo $head;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question