...

View Full Version : Resolved DomDocument get content in text file



RonnyNishimoto
08-14-2012, 09:07 PM
Hello!

I was able to get the content by ID and tag names, but I am wondering how can I just get all the contents from a text file (which doesn't have any markup)?



<?php
$doc = new DomDocument;
$doc->validateOnParse = true;
$doc->loadHtml(file_get_contents("test.html"));
$t = ($doc->getElementById("patch"));
print $t->nodeValue;
?>


Thanks :)

mlseim
08-14-2012, 09:23 PM
$lines=file("mytextfile.txt");
foreach($lines as $line){
echo $line;
}

Fou-Lu
08-14-2012, 09:35 PM
Yep, or file_get_contents, or standard fopen/fread.
DOM is only useful if it has an actual document object model to process. Flat files require a flat reading technique.

RonnyNishimoto
08-15-2012, 12:39 AM
Haha, yeah I was probably going overboard on Dom, I just discovered it.

Thanks guys!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum