Home > Web Front-end > JS Tutorial > JavaScript XML and string conversion implementation code_javascript skills

JavaScript XML and string conversion implementation code_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:05:15
Original
1079 people have browsed it

复制代码 代码如下:

//convert string to xml object
function String2XML(xmlString) {
// for IE
if (window.ActiveXObject) {
var xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async = "false";
xmlobject.loadXML(xmlstring);
return xmlobject;
}
// for other browsers
else {
var parser = new DOMParser();
var xmlobject = parser.parseFromString(xmlstring, "text/xml");
return xmlobject;
}
}
//convert xml object to string
function XML2String(xmlObject) {
// for IE
if (window.ActiveXObject) {
return xmlobject.xml;
}
// for other browsers
else {
return (new XMLSerializer()).serializeToString(xmlobject);
}
}
Related labels:
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
Latest Issues
objective-c - socket sends data in xml format
From 1970-01-01 08:00:00
0
0
0
How to parse and process HTML/XML in PHP?
From 1970-01-01 08:00:00
0
0
0
How to parse and process HTML/XML in PHP?
From 1970-01-01 08:00:00
0
0
0
How to parse and process HTML/XML using PHP?
From 1970-01-01 08:00:00
0
0
0
Update xml namespace with data from PHP form
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template