To convert a string into an xml object on the java side, you can use DocumentHelper.parseText(xmlReturn).getRootElement();
There is also a method to convert a string into an xml object in js. You can use the following function
The following is Quote snippet:
function createXml(str){
if(document.all){
var xmlDom=new ActiveXObject("Microsoft.XMLDOM")
xmlDom.loadXML(str)
return xmlDom
}
else
return new DOMParser ().parseFromString(str, "text/xml")
}
If you read the file on the js side, it will be more convenient
The following is a quote fragment:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0") ;
xmlDoc.async = false;
Quite convenient.
The following is a quotation fragment:
var code=domxml.getElementsByTagName("code");
if(code.item(0).text=="100"){
var parameter=domxml.getElementsByTagName ("parameter");
identifier=parameter.item(0).attributes.getNamedItem("value").value;
}
For the value of the node and the value of the attribute The methods of obtaining are different.
The following method
function toXmlDom(source){
var xmlDoc = null;
if (window.ActiveXObject) {
var ARR_ACTIVEX =
["MSXML4.DOMDocument","MSXML3.DOMDocument", "MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XmlDom"];
var XmlDomflag = false;
for (var i = 0;i < ARR_ACTIVEX.length && !XmlDomflag ;i ) {
try {
var objXML = new ActiveXObject(ARR_ACTIVEX[i]);
xmlDoc = objXML;
XmlDomflag = true;
} catch (e) {
}
}
if (xmlDoc) {
xmlDoc.async = false;
xmlDoc.loadXML(source);
}
}else{
var parser=new DOMParser();
var xmlDoc=parser.parseFromString(source,"text/xml");
}
return xmlDoc;
}
function areaChart(data){
var s = toXmlDom(xml);/ /xml is a string
$(s).find("area").each( //Get each area tag
function(id,item){
var areaCode=$(item). find("area_code").eq(0).text();//Get the content of the area tag
var num = $(item).find("area_all_num").eq(0).text();
var name=$(item).find("area_name").eq(0).text();
var title=name "," num;
$("#" areaCode "" ).attr("title",title);
}
);
Statement: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