I want to be able to do something like
var XMLquerry:String = "a1.a2.a3";
var parserVal:XML = parserMethod(XMLquerry);
// or
var parserVal:XMLList = parserMethod(XMLquerry);`
and get an output something like
<a3>Some value</a3>
Important: And I want to be able to replace the output at a1.a2.a3 so using decedents is out of question. :(
So it's basically the ability to call xml quarry in string. Is there a way to do this. Just a hint would be super, I can do it if I got a bit of head-start.
Thank You!
I think I found a solution with the help from this link:
public static function updateXml(xml:XML, path:String, data:XMLList = null,update:Boolean = false,XmlListOnly:Boolean = false):* {
var nodesArray:Array = path.split(".");
var tempXML:XML = xml;
var tempXMLCandidate:XML;
var tagName:String;
for (var i:int = 0; i < nodesArray.length; i++){
tagName = nodesArray[i];
if (i == nodesArray.length - 1){
if (data != null && update && !XmlListOnly){
tempXML[tagName] = data;
}else if (XmlListOnly){
return tempXML[tagName];
}else{
return tempXML[tagName].length();
}
}else{
tempXMLCandidate = tempXML[tagName][0];
if (!tempXMLCandidate){
tempXML.appendChild(tempXMLCandidate);
}
tempXML = tempXMLCandidate;
}
}
return tempXML;
}
You can call it like this:
updateXml(xmlHold, "words.exercise", sortedXmlList, true);