var query:String = "greenwich";
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("http://search.twitter.com/search.atom?lang=en&q="+query));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event) {
myXML = new XML(e.target.data);
myXML = removeNS(myXML);
// then use myXML object as normal to access various parts of the feed
for (var i:int = 0; i < myXML.entry.length(); i++){
trace(myXML.entry.title[i]);
}
}
function removeNS(anXML:XML){
var xmlString = anXML.toXMLString();
var xmlnsPattern = new RegExp("xmlns[^\"]*\"[^\"]*\"", "gi");
var namespaceRemovedXML = xmlString.replace(xmlnsPattern, "");
var aaaPattern = new RegExp("aaa:lang[^\"]*\"[^\"]*\"", "gi");
var aaaRemovedXML = namespaceRemovedXML.replace(aaaPattern, "");
var twitterPattern = new RegExp("twitter:", "gi");
var twitterRemovedXML = aaaRemovedXML.replace(twitterPattern,"");
var openSearchPattern = new RegExp("openSearch:", "gi");
var openSearchRemovedXML = twitterRemovedXML.replace(openSearchPattern,"");
var responseXML = new XML(openSearchRemovedXML);
return responseXML;
}