0

I'm trying to read from an XML dictionary file* to populate a MySQL database. I've got a script prepped and tested that, once I can get the data to load, will process everything properly. Unfortunately, I am stuck on the data read portion.

How can I get PHP to read my XML file and pull each complete entry in sequence for processing?

'* Specifically, KANJIDIC: http://www.csse.monash.edu.au/~jwb/kanjidic2/

Kaji
  • 2,220
  • 6
  • 30
  • 45

1 Answers1

0

If it's in individual files, you can just pass each entry's URL in DOMDocument::load().

If it's one large XML file, you may want to instead use XMLReader - still, you can pass the URL into XMLReader::open(), then use next() to move from one entry to another. Use XMLReader::expand() to get each entry's details as a DOM object.

Same applies if it's a local copy - point to the file path.

boen_robot
  • 1,450
  • 12
  • 24