XPath と PHP で Web ページをリート (1337) に変換したい。
これは PHP のみで実行できますが、HTML ノードも leet speak に置き換えられます。
例 ($html は Web ページです):
$find = array("a","b","c","d","e","f","g","h","i","j"."k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
$repl = array("4","b","c","d","3","f","g","h","1","j","k","1","m","n","0","p","9","r","5","7","u","v","w","x","y","2");
$html = str_replace($find, $repl, $html);
これにより、HTML ノードも置き換えられます。
これは、XPath セレクターtext()を使用して XPath と PHP で実行できますか? 例 ($html は Web ページです):
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$xpath->query('//text()');
\\HERE THE REPLACING IN XPATH