WGet is a pretty awesome tool for many reasons. But there’s a handy trick I picked up today while I tried to scan a website for broken links. Continue reading Scan a Website for Broken Links With WGet
Month: August 2013
XMLDom::Save() Permission Problem
I had been hitting my head against the wall when I couldn’t get an edited XML file to save due to file permissions, even though I know that it was OK.
For some odd reason, when I went to save the XML file, it would try to write the file to the root directory, instead of the current working directory (where the file is read from).
As such, using realpath() to keep the complete system path to the XML file when you load it will make sure that DOM isn’t trying to save to the incorrect directory:
$myfile = 'myxml.xml'; $myfile = realpath($myfile); $doc = new DOMDocument('1.0'); $doc->load($myfile); // Let's just add a couple of elements for good measure $root = $doc->documentElement; $title = $doc->createElement('title'); $title = $root->appendChild($title); $text = $doc->createTextNode('This is a title'); $text = $title->appendChild($text); $doc->save($myfile);
Getting CDATA values using DOM and XPath in PHP
That title is a mouthful, isn’t it?
Anyway – one of the recent issues I’ve had in my coding journey is using DOM and XPath in conjunction to navigate around an AML document. The problem came when the text values in an element would be wrapped in a CDATA tag: Continue reading Getting CDATA values using DOM and XPath in PHP