-1

I have been trying Simple XML but I can not navigate through the structure of the file. This is the URL I am trying to parse. https://ws.brreg.no/lod/data/982463718

Shef
  • 44,808
  • 15
  • 79
  • 90
Ahmad Farid
  • 14,398
  • 45
  • 96
  • 136
  • You'll need to be more specific about your problem. What does "I can not navigate" mean? "I don't know how to" or "When I run this code XXX happens", or something else? – Colin Fine Oct 27 '10 at 10:30
  • possible duplicate of [Best XML Parser for PHP](http://stackoverflow.com/questions/188414/best-xml-parser-for-php) – Gordon Oct 27 '10 at 10:32
  • for example, this code does not print anything: $xmlAddress = simplexml_load_file("https://ws.brreg.no/lod/data/982463718"); print $xmlAddress; – Ahmad Farid Oct 27 '10 at 10:36
  • You cant expect use to write a SimpleXml Tutorial for you. [There is examples for it's usage in the PHP Manual](http://uk2.php.net/manual/en/simplexml.examples-basic.php) and [on the web](http://www.google.com/search?q=simplexml+tutorial). Please look at these first and when you have any specific problems, ask here. – Gordon Oct 27 '10 at 10:39
  • This produces warnings, doesnt print: $xmlAddress = simplexml_load_string("https://ws.brreg.no/lod/data/982463718"); Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, '<' not found in /home/min/sesam4/www/webservice/portal.php on line 31 Warning: simplexml_load_string() [function.simplexml-load-string]: https://ws.brreg.no/lod/data/982463718 in /home/min/sesam4/www/webservice/portal.php on line 31 Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/min/sesam4/www/webservice/portal.php on line 31 – Ahmad Farid Oct 27 '10 at 10:40
  • Also, please use the [Edit function](http://stackoverflow.com/posts/4032157/edit) to provide more details to your question, especially if it needs formatting. In addition, you have already asked a highly similar question with [How to receive XML data produced by a website(webservice) in PHP?](http://stackoverflow.com/questions/3975936/how-to-receive-xml-data-produced-by-a-websitewebservice-in-php) – Gordon Oct 27 '10 at 10:41
  • Can anyone check the URL I'm trying to parse, because I get an error saying "this is not an XML file" Is this true? – Ahmad Farid Oct 27 '10 at 10:44
  • No, it's not true. It loads fine with DOM. – Gordon Oct 27 '10 at 11:02

1 Answers1

0

Have you looked at what you're receiving from that site? Instead of feeding the content directly to simpleXML, capturee it in a variable instead and output that. Perhaps you've been banned from that site for exessive usage, and you're getting a 401-denied error page instead of the XML you're expecting:

$content = file_get_contents('https://ws.brreg.no/lod/data/982463718');
echo '<pre>', htmlspecialchars($content), '</pre>';
Marc B
  • 356,200
  • 43
  • 426
  • 500