Convert XML to String and append to page

前端 未结 6 1224
清酒与你
清酒与你 2020-12-08 07:31

I want to convert an xml element like this:

​B0013FRNKG​

to string in java

6条回答
  •  眼角桃花
    2020-12-08 07:54

    follow this to print,append data from xml data stored as string inside javscript

    txt=""+""+
     "athor name"+
    "title"+
    "path"+
    "which tack"+
     ""+
    ""+
    "athor name"+
    "title"+
    "path"+
    "which tack"+
    ""+
    ""+
    "athor name"+
    "title"+
    "path"+
    "which tack"+
    ""+
    "";
    if (window.DOMParser)
      {
          parser=new DOMParser();
      xmlDoc=parser.parseFromString(txt,"text/xml");
    
       }
       else // Internet Explorer
        {
         xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
         xmlDoc.async=false;
         xmlDoc.loadXML(txt);
        }
    
    x=xmlDoc.getElementsByTagName("paper"); 
    for (var i = 0; i < x.length; i++) {  
        var athor =x[i].childNodes[0].firstChild.nodeValue;
        var title = x[i].childNodes[1].firstChild.nodeValue;
        var path = x[i].childNodes[2].firstChild.nodeValue;
        var tack =x[i].childNodes[3].firstChild.nodeValue;
        //do something with these values...
        //each iteration gives one paper details    
        var xml=document.getElementById("element_id");//
    var li = document.createElement("br");// create a new
    newlink = document.createElement('A'); // creating an element newlink.innerHTML = athor;// adding athor value here newlink.setAttribute('href', path);// newlink.appendChild(li);// athor
    document.getElementById("element_id").appendChild(newlink);//finaly it becomes }

提交回复
热议问题