Php+xml realization of online English Dictionary query method, XML English Dictionary _php tutorial

Source: Internet
Author: User

Php+xml realization of online English Dictionary query method, XML English Dictionary


This paper describes the method of Php+xml to realize online English dictionary query. Share to everyone for your reference. Specific as follows:

The XML here is equivalent to a database. Implementation: Query An English word, output its Chinese meaning.

XML file (database): Words.xml as follows:
Copy the Code code as follows: <?xml version= "1.0" encoding= "Utf-8"?>


Boy
Boy


Girl
Girl


Teacher
Teacher


Beauty
Beauty

Query file: word.php
Copy the Code code as follows:

Online English-Chinese Dictionary


Processing files: xmlprocess.php
Copy the Code code as follows: <?php
Creating an XML Object
$xmldoc = new DOMDocument ();
$xmldoc->load ("Words.xml");
Inquire
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 is not found";
}
}
}
echo $CN _word;
?>

I hope this article is helpful to everyone's PHP operation XML programming.

http://www.bkjia.com/PHPjc/946733.html www.bkjia.com true http://www.bkjia.com/PHPjc/946733.html techarticle php+xml realization of online English Dictionary query method, XML English Dictionary This paper describes the Php+xml realization of online English Dictionary query method. Share to everyone for your reference. Specific as follows: ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.