I'm using an xml file to gather informations about my employees (hours of work and such) and I want to show these infos in a page on the website of the company based on the employee logged in. To do so I thought I could create a shortcode, here is the code I'm using:
function register_xml_file() {
wp_register_style( 'porva', get_stylesheet_directory_uri() . '/porva.xml' );
wp_enqueue_style( 'porva' );
}
add_action( 'wp_enqueue_scripts', 'register_xml_file' );
function dati_tbcrew($atts){
global $user_login;
get_currentuserinfo();
$percorso=get_stylesheet_directory_uri();
$percorso.="/porva.xml";
$xml=simplexml_load_file($percorso) or die("Error: Cannot create object");
switch($xml->name['nome']){
case $user_login: $out=$xml->name->contenuto;break;
default:break;
}
return $out;
}
add_shortcode('dati_tbcrew', 'dati_tbcrew');
Unfortunately the output is:
Error: Cannot create object
Why can't simplexml_load_file find the xml file?