Jump to content

PHP XML Error


PriteshP23
Go to solution Solved by PriteshP23,

Recommended Posts

Hello,

 

I am trying to read XML file and store in sql table. I got two errors.

 

PHP Warning:  XMLReader::open(): Unable to open source data

 

Warning: XMLReader::read(): Load Data before trying to read

 

How to solve it ?

 

THANKS IN ADVANCED.

$reader = new XMLReader;
$reader->open('filename.xml');
while($reader->read())
{
    ///
 }
Edited by PriteshP23
Link to comment
Share on other sites

Seriously?

 

The line "XMLReader::open(): Unable to open source data" is there to to tell that the file is either not where you are teilling the script it is, does not exist at all, or does not have sufficient permissions set for the script to open it for reading.  If the script can't open the file it's never going to manage to read it - hence the second warning message.

 

Without information on your file structure that's all I got.

Link to comment
Share on other sites

  • Solution

I think you are right. Please let me know the filename in below cases.

 

case 1:

$reader->open($topdir."/nap/".$code->no()."_city.xml");

 

IF i run like      php user.php 01

                       php user.php

 

case 2:

$reader->open($topdir."/nap/"."01_city.xml");

 

IF i run like      php user.php 01

                       php user.php

 

I would like to know the working process.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.