javascript - How to find and replace xml node value in JQuery -


I need help finding and changing a value using JQuery in XML node, please tell me below that my scenario Is,

  var metadata = '& lt; Control type = "table" id = "4900a2a9-47d7-4d3b-9a35-fdd32b185730" & gt; & Lt; / Control & gt; & Lt; Control Type = "Text Box" ID = "7a49 9F6-16C1-4-88 9-A0-FA2A7Fi886" & gt; & Lt; / Control & gt; '; In the above XML structure, I want to search for id = "4900a2a9-47d7-4d3b-9a35-fdd32b185730" and replace it with id = "91e3cbe6-8168-40be-bf26-ccdd6acb1e17" "Please suggest in jQuery.  

Below I've tried,

  var oldID = "4900a2a9-47d7-4d3b-9a35-fdd32b185730"; Var newID = "91e3cbe6-8168-40be-bf26 The code above was not successful.   

itemprop = "text">

Just use the string in your xml variable, JS

  xml.repla ce ('4900a2a9-47d7-4d3b-9a35-fdd32b185730', '91e3cbe6-8168-40be-bf26-ccdd6acb1e17');   

  var xml = '& lt; control type =" table "id =" 4900a2a9-47d7 -4d3b-9a35-fdd32b185730 "& gt; & Lt; / control & gt; & Lt; Control Type = "Textbox" ID = "7a49 9F6-16C1-4fe8- 9ea0-fe02e7eef886" & gt; & Lt; / Control & gt; '; var result = xml.replace ('4900a2a9-47d7-4d3b-9a35-fdd32b185730', '91e3cbe6-8168-40be-bf26-ccdd6acb1e17'); $ ("#to") text (xml). $ ("# Results") Text (result);   
  & lt; script src = "https: //ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> & Lt; P & gt; Before: & lt; / P & gt; & Lt; Br / & gt; & Lt; Div id = 'from' & gt; & Lt; / Div & gt; & Lt; Br / & gt; & Lt; P & gt; After: & lt; / P & gt; & Lt; Br / & gt; & Lt; Div id = 'result' & gt;  gt;

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -