Jump to content

PHP DOM


bals28mjk

Recommended Posts

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

Thanks for specifying. Now can you specify that specification? :P

 

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.