mcberta2 Posted November 22, 2011 Share Posted November 22, 2011 Hello requinix. I am taking advantage of this thread to expose my problem: It looks like the load function does NOT work properly and I CANNOT find the reason why: $xml = new DOMDocument(); $xml->load("data/slides.xml"); In debugging, I can see the creation of a DOMDocument but the load function does not fill the $xml with the relative data even if it returns True: <?xml version="1.0" encoding="UTF-8"?> <album> <slide url="data/327.jpg" rel_URL="show_craft.php?id=327" title="Art. 327"></slide> <slide url="data/330.jpg" rel_URL="show_craft.php?id=330" title="Art. 330"></slide> <slide url="data/311.jpg" rel_URL="show_craft.php?id=311" title="Art. 311"></slide> <slide url="data/239.jpg" rel_URL="show_craft.php?id=239" title="Art. 239"></slide> <slide url="data/275.jpg" rel_URL="show_craft.php?id=275" title="Art. 275"></slide> <slide url="data/IMG_2691.jpg" rel_URL=" " title="Art. IMG_2691"></slide> <slide url="data/IMG_2684.jpg" rel_URL=" " title="Art. IMG_2684"></slide> <slide url="data/crafts 023.jpg" rel_URL=" " title="Art. crafts 023"></slide> </album> I use XAMPP 1.7.7. In php.net, under DOMDocument::load page, there is a post that says "Function will not work if using XML DOM PECL module". In my phpinfo() there is only the "PECL Module version 2.0-dev $Id: sqlite.c 306939 2011-01-01 02:19:59Z felipe $ " under SQLite section enabled. I tried many things like changing xml path, replacing the xml file with a simpler one from, for example, w3schools but with no avail. I still get an empty document. I don't know where to bang my head since it looks like it's only me having this issue (search the web extensively). Any help is greatly appreciated. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/251614-dom-xml-parsing-help/ Share on other sites More sharing options...
ManiacDan Posted November 22, 2011 Share Posted November 22, 2011 Please don't tack your problem on to an existing thread that has already been solved. Your post has been split off into its own thread. Do you have any errors to show us? you say that you can see things working, what else do you see? As this is XML, you may want to look into the SimpleXML library instead of the DOM. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/251614-dom-xml-parsing-help/#findComment-1290395 Share on other sites More sharing options...
mcberta2 Posted November 23, 2011 Author Share Posted November 23, 2011 I am sorry about that. It was my first post. No errors whatsoever. The function simply does not fill the Dom Document with the xml file ($xml remains empty). And the funny thing is that it returns True (1). The plan is to replace/modify/delete single nodes and the Dom Document is better than simplexml. But at this point I really want to know why it is doing this. Is it a configuration problem like "syntaxiko 05-Apr-2009 06:16" suggested on php.net? Or what? Thank you again. Quote Link to comment https://forums.phpfreaks.com/topic/251614-dom-xml-parsing-help/#findComment-1290690 Share on other sites More sharing options...
dreamwest Posted November 23, 2011 Share Posted November 23, 2011 SimpleXML is much easier $data = file_get_contents("superman.xml"); $n_data = new SimpleXmlElement($data, LIBXML_NOCDATA); foreach ($n_data->movies->movie as $d) { $show .= "{$d->friends} went to see {$d->title}<br />"; } echo $show; Quote Link to comment https://forums.phpfreaks.com/topic/251614-dom-xml-parsing-help/#findComment-1290695 Share on other sites More sharing options...
mcberta2 Posted November 23, 2011 Author Share Posted November 23, 2011 Thank you for your reply. Very neat. I found out that the debugger (XDebug on Netbeans) does not show the content of the DomDocument and so my assumption that the function "load" wasn't working. Thank you for coming Quote Link to comment https://forums.phpfreaks.com/topic/251614-dom-xml-parsing-help/#findComment-1290740 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.