0

I am learning how to parse in various languages. Right now I am trying to learn PHP. Can anyone help get me started?

http://www.nfl.com/liveupdate/scorestrip/ss.xml

is the page I would like to parse using PHP. Is this possible and how do you do it with PHP?

3 Answers 3

2

Try this:

<?php
  $xml=simplexml_load_file('http://www.nfl.com/liveupdate/scorestrip/ss.xml');
  print_r($xml);
?>

http://www.php.net/manual/en/book.simplexml.php

Sign up to request clarification or add additional context in comments.

1 Comment

You can use the url directly in simplexml_load_file() if the fopen wrappers are enabled
0

Simple XML is good if you need a DOM interface to the XML, but if you need something quick just to go from XML into an associative array there's a great utility script that's super simple online:

http://www.bin-co.com/php/scripts/xml2array/

I've only used it for internal xml files, so its worth a security audit if you're using external xml

Comments

0

simplexml_load_file() is really a good start for this. note here, $xml is not an array. if you want to save more records in your database, use it in a proper way. print_r($xml) will help you to get the better structure .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.