allencoded
allencoded

Reputation: 7275

How to parse XML using PHP no code?

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?

Upvotes: 0

Views: 186

Answers (3)

Gaurav
Gaurav

Reputation: 628

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 .

Upvotes: 0

C.J.
C.J.

Reputation: 249

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

Upvotes: 0

stewe
stewe

Reputation: 42654

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

Upvotes: 2

Related Questions