If you ever plan to use XML with PHP there is good XMLParser class written by Adam A Flynn. You can get it for PHP4 and PHP5 from his page
http://www.phppal.com/xml/doc.php. There are some examples, so it wont be very hard to understand.
UPDATE: seemes, that www.phppal.com is dead allready :/
You can download the class from my page: XMLParser.zip
To use this class simply copy it in /usr/lib/php directory or if you dont have root permissions, copy in the same folder as your php script.
I had some problems at first, because I was not familiar with data structure after parsing, so I used such code to view, how objects and arrays was formed:
Parse
();
//Print all xml children array structure
print_r($parser->document->tagChildren);
That’s all. It is much simplier than i thought to work with XML :)
More info at php documentation: http://lt.php.net/manual/en/ref.xml.php
UPDATE: As PHP5 has much better XML support, you can use now it’s features Read on Zend article
Recently I was writing Bash shell script, which moves files and directories from one server to other. As files and folders are created by end users, there are problems about file names.
Users create folders with spaces e.g. very important and Bash script interprets it as two separate folders: very and important when my script finds all folders and starts to move them, I get error on folders with spaces. This is the command:
mv -fv `find /mnt/volume/tomove -mtime +14` /path/tomovewhere
This piece of code moves files and folders older than 14 days from /mnt/volume/tomove to /path/tomovewhere
So, if there is folder /mnt/volume/tomove/very important
Bash tries to move /mnt/volume/tomove/very and important
To interpret directories as one command you will need to add this variable to your script:
IFS=$‘\n‘
$IFS is internal field separator, this variable determines how Bash recognizes fields, or word boundaries, when it interprets character strings.
You can find more info with samples here:
http://tldp.org/LDP/abs/html/internalvariables.html