bals28mjk Posted July 3, 2008 Share Posted July 3, 2008 Hey. Has anyone worked with the PHP DOM here? I'm trying to get data from files with .php extensions. It allows for xml, html, but I couldn't find anything for .php extensions. It's important to note that you are allowed to add html/xml text for the DOM classes in the form of a string. Though, I only know how to get data from asource file with PHP; how would you grab the file after all PHP parsing? Can someone help me out? What's the best way of going about this? Thanks. Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/ Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 Open the PHP file with the HTTP wrapper, so you have its output. Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-580785 Share on other sites More sharing options...
bals28mjk Posted July 3, 2008 Author Share Posted July 3, 2008 Hey DarkWater thanks for the reply, I'm not sure exactly what you mean, would you mind specifying? Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-580877 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 Instead of opening the file directly on the server, specify the full path name so that PHP uses the HTTP wrapper to access the file instead of accessing it with the filesystem handlers. Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-580880 Share on other sites More sharing options...
bals28mjk Posted July 3, 2008 Author Share Posted July 3, 2008 Thanks for specifying. Now can you specify that specification? This is pretty much what you told me not to do, but maybe a visual can help. I don't know how else to open the file and this outputs only the source: $d=new DOMDocument; $f=file_get_contents($fullPath); $d->loadHTML($f); echo $d->getElementById("d")->nodeValue; Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-580975 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 What's in $fullPath? Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-581002 Share on other sites More sharing options...
bals28mjk Posted July 3, 2008 Author Share Posted July 3, 2008 Hey DarkWater, thanks for the help, another person helped me with this and fortunately, I got it now. I can kind of see where you were going with this. I'm starting the path with http:// instead of c:\\. Is that what you were referring to? Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-581020 Share on other sites More sharing options...
mbeals Posted July 3, 2008 Share Posted July 3, 2008 Hey DarkWater, thanks for the help, another person helped me with this and fortunately, I got it now. I can kind of see where you were going with this. I'm starting the path with http:// instead of c:\\. Is that what you were referring to? without putting words in DarkWater's mouth.... yes. When you open the php script through the http://, the script is being executed and you are reading the output of the script. It could be html, xml or whatever you code the script to return. Accessing it through C:/ is opening the raw source file, which is just php code. Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-581026 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 Hey DarkWater, thanks for the help, another person helped me with this and fortunately, I got it now. I can kind of see where you were going with this. I'm starting the path with http:// instead of c:\\. Is that what you were referring to? without putting words in DarkWater's mouth.... yes. When you open the php script through the http://, the script is being executed and you are reading the output of the script. It could be html, xml or whatever you code the script to return. Accessing it through C:/ is opening the raw source file, which is just php code. Yup. http:// signifies the use of PHP's HTTP wrapper for file functions (there are other wrappers like ogg: and compress.zlib: and stuff too), instead of using the default wrapper (file:). Link to comment https://forums.phpfreaks.com/topic/113073-php-dom/#findComment-581029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.