Merging two XML files in Flex
Does anyone know how to merge two xml files in or two xmllist 开发者_如何学编程objects in Flex3 ActionScript?
Thanks.
Assuming you just want to append:
//all items from 2 are now added to 1
for each(var item:xml in myXMLList2){
myXMLList1.appendChild(item);
}
//all items added to new XMLlist
var myMergedXMLList:XMLList;
for each(var item:xml in myXMLList1){
myMergedXMLList.appendChild(item);
}
for each(var item:xml in myXMLList2){
myMergedXMLList.appendChild(item);
}
I applied part of what invertedSpear suggested and got it to work. Thank everyone for commenting/answering.
var xmlstr1:String = "My Value 1My Value 2"
var xmlstr2:String = "My Value 3My Value 4"
var xml1:XML; var xml2:XML;
var xmlst1:XMLList; var xmlst2:XMLList; var xmlstMerged:XMLList = new XMLList(); var item:XML
xml1 = XML(xmlstr1); xml2 = XML(xmlstr2);
xmlst1 = new XMLList(xml1); xmlst2 = xml2.document;
for each(item in xmlst2){ xmlst1.appendChild(item); }
xmlstMerged = xml1.document;
精彩评论