I have a problem with php,
If I implement this code below then nothing will be happen.
$filename = "/opt/olat/olatdata/bcroot/course/85235053647606/runstructure.xml"; if (file_exists($filename)) { $xml = simplexml_load_file($filename, 'SimpleXMLElement', LIBXML_NOCDATA); // $xpath = new DOMXPath($filename); } $doc = new DOMDocument(); $doc->loadXML($xml); $xpath = new DOMXpath($doc); $res = $xpath->query('/org.olat.course.Structure/rootNode/children/org.olat.course.nodes.STCourseNode/shortTitle'); foreach ($res as $entry) { echo "{$entry->nodeValue}<br/>"; }
If I change the contents of $xml in the content with the content of the $filename
$xml = '<org.olat.course.Structure><rootNode class="org.olat.course.nodes.STCourseNode"> ... ';then it works, so i think that there is something wrong with loading methode of the xml file,
I’ve also tried to load the xml file as a Domdocument but it won’t work neither.
And in both cases, it does work if I collect xml data via xml
for example this worksecho $Course_name = $xml->rootNode->longTitle;
loadXMLtakes a string as input, not the return value ofsimplexml_load_file. Just usefile_get_contentsto get the (full) contents of a file as string