jbooth952 Posted November 19, 2010 Share Posted November 19, 2010 Does the file have to be in the document root? If not, what is the correct syntax to point simplexml_load_file() to a directory on the server that is not the document root? ie what goes between the () this works fine if the .xml file is in my public html root - simplexml_load_file('sample.xml') but when I put the file in a different directory on the server, I can't figure out how to point to it. Help is appreciated. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 19, 2010 Share Posted November 19, 2010 What is the path to the file? If it's outside of the doroot (not a subdir in docroot) you put that full path: /path/to/file/sample.xml If it's in a subdir of the docroot then you can use the full path or a relative one like (if it is in the docroot/files/xml dir): files/xml/sample.xml Also, add this to show errors in case there are permission issues, etc... error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
jbooth952 Posted November 19, 2010 Author Share Posted November 19, 2010 Thanks. I pointed to the full path name in the script like this; simplexml_load_file('/home/userid/xmldata/sampleXML.xml'); and when I run the script from my production root, it works fine. For testing I put my scripts in a sub directory of public_html (my root) when I run the script from there, it can't find the file. Do I have to change simplexml_load_file('/home/ezsched/xmldata/assignXML.xml'); when I'm running from the test directory? What is the path to the file? If it's outside of the doroot (not a subdir in docroot) you put that full path: /path/to/file/sample.xml If it's in a subdir of the docroot then you can use the full path or a relative one like (if it is in the docroot/files/xml dir): files/xml/sample.xml Also, add this to show errors in case there are permission issues, etc... error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
jbooth952 Posted November 19, 2010 Author Share Posted November 19, 2010 Disregard the last post, I got it working. It finds the file from both the prod and test area using the same path parm. Thanks for your help. Thanks. I pointed to the full path name in the script like this; simplexml_load_file('/home/userid/xmldata/sampleXML.xml'); and when I run the script from my production root, it works fine. For testing I put my scripts in a sub directory of public_html (my root) when I run the script from there, it can't find the file. Do I have to change simplexml_load_file('/home/ezsched/xmldata/assignXML.xml'); when I'm running from the test directory? What is the path to the file? If it's outside of the doroot (not a subdir in docroot) you put that full path: /path/to/file/sample.xml If it's in a subdir of the docroot then you can use the full path or a relative one like (if it is in the docroot/files/xml dir): files/xml/sample.xml Also, add this to show errors in case there are permission issues, etc... error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.