I've been trying to get this working for some time now but having no luck. Here's the code that I'm having trouble with, read on to understand my problem:
Code: Select all
$doc = new DOMDocument();
$doc->load($gigToSearch."GigInfo.xml"); // This is the problem.. It doesn't like it unless it's a file already there.
$venues = $doc->getElementsByTagName("event");
$fp2 = fopen($gigToSearch."Venue.xml", "w");
foreach ($venues as $venue) {
$venuesID = $venue->getElementsByTagName("id");
$venueID = $venuesID->item(0)->nodeValue;
fwrite($fp2, '<id>');
fwrite($fp2, $venueID);
fwrite($fp2, '</id>');
}
fclose($fp2);
If I use:
Code: Select all
$doc->load("MuseGigInfo.xml");But the problem is, I can't specify an exact XML file as depending on user input an XML file is downloaded and saved locally on the server with the appropriate name, which can then only be accessed using $gigToSearch."GigInfo.xml" like I do in my code to be able to fetch some data I need.
Using the original code I provided above it gives me the following error:
Warning: DOMDocument::load()[domdocument.load]: Document is empty file:///..../MuseGigInfo.xml
If I replace $gigToSearch."GigInfo.xml" with "MuseGigInfo.xml" and just try run an example for Muse it works fine.
I make sure I first download and write the file (and close it of course), but it still doesn't work.
Anyone have any ideas? The only thing I can think about is that $doc->load(); doesn't like anything but a statement enclosed inside quotes.
Thanks in advance!