Home > Web Front-end > JS Tutorial > body text

jQuery parsing and reading XML file method (with code)

php中世界最好的语言
Release: 2018-04-23 14:42:58
Original
1562 people have browsed it

This time I will bring you the method of jQuery parsing and reading XML files (with code). What are the precautions for jQuery parsing and reading XML files. The following is a practical case, let's take a look.

In the project, jQuery is used to parse and read the XML language Configuration file to implement language scheduling. This is the test source code for jQuery’s function of parsing and reading XML files. I will share it now.

I am working on a project recently. Because the page uses cookies, it is necessary to determine whether the user's browser supports cookies and prompt the user how to turn on the cookie function of the browser. At the same time, the entire project must be configured with multi-language support, including Chinese, Vietnamese, Japanese and English, so a language configuration file is required. In the project, jQuery is used to parse and read XML language configuration files to implement language scheduling. This is the test source code for jQuery’s function of parsing and reading XML files. I will share it now.
Directory structure:
main.css file code:

@CHARSET "UTF-8"; 
* { 
margin: 0px; 
padding: 0px; 
} 
body { 
width: 800px; 
text-align: left; 
font-size:62.5%; 
font: normal 0.75em tahoma, helvetica, sans-serif; 
} 
#Message_error { 
height:16px; 
color:#000; 
line-height:16px; 
background:#fcc url(image/msg_error.png) no-repeat; 
margin-bottom
:2px; 
border-bottom:#faa 1px solid; 
padding-left
:20px; 
overflow:hidden; 
display:none; 
} 
#Message_success { 
height:16px; 
line-height:16px; 
color:#000; 
background:#cfc url(image/msg_success.png) no-repeat; 
margin-bottom:2px; 
border-bottom:#afa 1px solid; 
padding-left:20px; 
overflow:hidden; 
display:none; 
}
Copy after login

index.html file code:

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>jQuery行级读取XML文件</title> 
<link rel="stylesheet" href="main.css" href="main.css" type="text/css"/> 
<script type="text/javascript" src="jquery-1.3.2.js"></script> 
<script type="text/javascript" src="browser.js" ><script> 
</head> 
<body> 
<p id="Message_success"></p> 
<p id="Message_error"></p> 
</body> 
</html>
Copy after login

MsgConfig_zh.xml file code:

<?xml version="1.0" encoding="utf-8"?> <Msg-Config> <msg id="1" name="cookie-support"> <message>你的浏览器不支持Cookie,请开启浏览器的Cookie功能</message> <message-help>点击查看开启Cookie方法</message-help> <message-url>index.html</message-url> </msg> <msg id="2" name="load-xml"> <message>jQuery读取节点XML成功</message> </msg> </Msg-Config>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of jquery dynamic loading of js files

Detailed explanation of the steps of asynchronous uploading of files by PHP jQuery plug-in

The above is the detailed content of jQuery parsing and reading XML file method (with code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template