[PHP/DOM]remove a XML node itself

We can remove a child node in Dom by php (example from php.nex):

$doc = new DOMDocument;
$doc->load('book.xml');

$book = $doc->documentElement;

// we retrieve the chapter and remove it from the book
$chapter = $book->getElementsByTagName('chapter')->item(0);
$oldchapter = $book->removeChild($chapter);

echo $doc->saveXML();

But if you want to delete the node itself, you could do something like this, it will delete the first appearance of the node:

$dom = new DomDocument();
$doc = $dom->loadXML($strXml);
$tagName = $dom->getElementsByTagName('tagName')->item(0);
$tagName->parentNode->removeChild($tagName);
echo $dom->saveXML();

Installation and configuration of PHPUnit in Windows

Installation and configuration of PHPUnit in Windows

Version control

Language:PHP 5.3.0(>5.2.7)
Web Server:WampServer Version 2.0
System:Windows 7
Folder path:c:\wamp\bin\php
PHP version should greater than 5.2.7. To install a new version of PHP, click the icon of Wamp, and then php->Version -> Get more.

Attention: if you install a new version PHP, after the installation, it is better to check the environment variable PHP_PEAR_PHP_BIN is point to the new folder of PHP. And the php.ini which will used by command line is the one you could find in the new folder of PHP.

Continue reading

Problem installing PEAR and solution

Today during the confirgration of my phpUnit, when I run C:\wamp\bin\php\php5.3.5>go-pear.bat

I met this problem :

C:\wamp\bin\php\php5.3.5\go-pear.bat

phar “C:\wamp\bin\php\php5.3.5\PEAR\go-pear.phar” does not have a signaturePHP Warning: require_once(phar://go-pear.phar/index.php): failed to open stream: phar error: invalid url or non-existent phar “phar://go-pear.phar/index.php” in C:\wamp\bin\php\php5.3.5\PEAR\go-pear.phar on line 1236

Solution :

Find this code in C:\wamp\bin\php\php5.3.5\php.ini :

[Phar]
; http://php.net/phar.readonly
;phar.readonly = On

; http://php.net/phar.require-hash
;phar.require_hash = On

;phar.cache_list =

Change it to :

[Phar]
; http://php.net/phar.readonly
;phar.readonly = On

; http://php.net/phar.require-hash
phar.require_hash = Off

;phar.cache_list =

A similar problem in stackoverflow :

http://stackoverflow.com/questions/1652941/why-am-i-receiving-an-error-when-installing-pear

[self] french vocabulary

====29/09/2011====

un pixel mort 坏点

un feutre 白板笔

une doudoune 羽绒服,滑雪服

un bordel

une citrouille 南瓜

un drone 无人飞机

virer (口语) = supprimer

moisir 发霉

rectifier 纠正

une connerie = une bêtise

un bouchon 瓶塞,堵车(项目里指模拟数据)

##中国文化##

une cacahouète 花生,长生果

nid d’hirondelle 燕窝

œuf centenaire 皮蛋

mandchourie 满洲

Yantsé, fleuve Bleu 长江(6000km)

fleuve jaune 黄河(5000km)

Turkestan oriental 新疆(désert de gobi)

Mongolie-Intérieure 内蒙古

Continue reading