php+xml method to implement online English dictionary query, xml English dictionary
The example in this article describes the method of php+xml to implement online English dictionary query. Share it with everyone for your reference. The details are as follows:
The xml here is equivalent to a database. Implementation: Query an English word and output its Chinese meaning.
xml file (database): words.xml is as follows:
Copy code The code is as follows:
boy
Boy
girl
Girl
teacher
Teacher
beauty
Beauty
Query file: word.php
Copy code The code is as follows:
Online English-Chinese Dictionary
Processing file: xmlprocess.php
Copy code The code is as follows:
//Create xml object
$xmldoc = new DOMDocument();
$xmldoc->load("words.xml");
//Query
if(!empty($_POST['sub'])){
$en_word = $_POST['enword'];
$word = $xmldoc->getElementsByTagName("en");
for($i=0;$i<$word->length;$i++){
if($en_word==$word->item($i)->nodeValue){
$cn_word = $xmldoc->getElementsByTagName("ch")->item($i)->nodeValue;
break;
}else{
$cn_word = "The word you entered cannot be found";
}
}
}
echo $cn_word;
?>
I hope this article will be helpful to everyone’s PHP XML programming design.
http://www.bkjia.com/PHPjc/946733.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/946733.htmlTechArticleHow to implement online English dictionary query with php+xml, xml English dictionary This article describes the implementation of online English with php+xml Dictionary query method. Share it with everyone for your reference. The details are as follows:...