# Search and replace xml text

**URL:** <https://forum.kirupa.com/t/search-and-replace-xml-text/262892>\
**Category:** flash\
**Created:** [June 10, 2008, 9:05pm UTC](https://forum.kirupa.com/t/search-and-replace-xml-text/262892 "2008-06-10T21:05:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![red2034](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@red2034](https://forum.kirupa.com/u/red2034)\
**Post date:** [June 10, 2008, 9:05pm UTC](https://forum.kirupa.com/t/search-and-replace-xml-text/262892/1 "2008-06-10T21:05:03Z")

</div>

ok - so I am loading XML and then trying to search and replace some of the text: see below for code (this is after all the xml load stuff…). It is not effecting the xml after loading??? please help.

function loadTxt(success:Boolean):Void {  
if (success) {

var allXML:XMLNode = txt.firstChild;

txtCSS = new TextField.StyleSheet();

cssURL = “css/style.css”;  
txtCSS.load(cssURL);

txtCSS.onLoad = function(success) {  
if (success) {  
scroller.txt.t.styleSheet = txtCSS; scroller.txt.t.autoSize = “left”;  
scroller.txt.t.html = true;  
scroller.txt.t.htmlText = allXML.childNodes[0].firstChild.nodeValue;  
}  
};  
searchAndReplace(scroller.txt.t.htmlText, “1”, “2”);  
} else {  
trace(“XML NOT LOADED”);  
}  
}

function searchAndReplace(holder, searchfor, replacement) {  
temparray = holder.split(searchfor);  
holder = temparray.join(replacement);  
return (holder);  
}
