We may have a requirement were we wanted to generate XML data to send through Httpservice or create a XML page with it.
Then here to get that XML type data we could use a little bit of ActionScript code like below.
Here iam using XML Class and XMLList Class.
First iam defining my RootNode of type XML and then node name and node value of Type String and Then create a XMLList using this node name and node value,and then append this to XML RootNode using the method appendChild().Thats it ur XML data is created, now we can extend this to generate any number of XML lines type data.
Code Example:
private function createXML(): void
{
var xm:XML = <Relyon></Relyon>;
var nodeName:String = “EMPLOYEENAME”;
var nodeValue:String = “KUMAR”;
var xmlList:XMLList = XMLList(“<”+nodeName+”>”+nodeValue+”</”+nodeName+”>”);
xm.appendChild(xmlList);
Alert.show(xm);
}
This will do the JOB. Leave any comments for queries.


April 9, 2008 at 6:32 pm |
Hi Kumar,
Thanks for the info,
how can I generate XML like this:
Thanks for any help.
April 22, 2008 at 11:31 am |
Hello Meena,
For this we got to use the some classes in flash.xml package, i can give another example for you.
[Bindable]
public var xml:XML
private function createXML():void
{
try
{
xml =
{content.text}
;
}
catch (e:TypeError)
{
xml = Fill the form to see the tag here.;
}
}
by this also we can generate dynamic xml data,By using XML class.
here tagName , attributeName are my TextInput Components.
regards,
kumar.
August 18, 2008 at 2:32 pm |
Hi Kumar,
Can you tell me how to bind the data of xml in the class file.
i mean to say i will be creating the class file there i need to get the xml data for manipulating.
Let me know if u have any idea about this
Thanks and Regards
Balaji
August 19, 2008 at 5:56 pm |
Hi,
I will come up with a post on this soon.
regards,
kumar
September 30, 2008 at 3:00 pm |
[...] XML Data dynamically in Flex :: Reloaded Few months back i made a post on this “Generate XML Data dynamically in Flex” and it needed some improvements. so here i am with the improvements. [ As few readers suggested [...]
December 2, 2008 at 7:10 am |
Want dynyamic XML
December 2, 2008 at 3:11 pm |
There are some methods in the XML class you can use those, here to get XML there is one method called toXMLString(), this will give out the XML in String format.try it.
or use the continuation post for this post,
http://flexonblog.wordpress.com/2008/09/30/generate-xml-data-dynamically-in-flex-reloaded/
regards,
kumar.
May 6, 2009 at 12:01 pm |
how to display & there……
i tried with & but its not working………….
May 6, 2009 at 1:45 pm |
Hi,
It will take that character, i don’t understand your problem, can you be clear.
regards,
kumar.
May 8, 2009 at 9:06 am |
How to add ampercent in xml node…….
this is the sample code…….
here i am giving & but its displaying as &
<![CDATA[
import mx.controls.TextArea;
import mx.controls.Text;
import mx.controls.Alert;
private function createXML(): void
{
var xm:XML = ;
var nodeName:String = "EMPLOYEENAME";
var nodevaule:Text=new Text();
nodevaule.text="&";
var xmlList:XML = {nodevaule.text};
xm.appendChild(xmlList);
Alert.show(xm.toXMLString());
}
]]>
May 11, 2009 at 11:13 am |
<![CDATA[
import mx.controls.TextArea;
import mx.controls.Text;
import mx.controls.Alert;
private function createXML(): void
{
var xm:XML = ;
var nodeName:String = "EMPLOYEENAME";
var nodevaule:Text=new Text();
nodevaule.text="&";
var xmlList:XML = {nodevaule.text};
xm.appendChild(xmlList);
Alert.show(xm.toXMLString());
}
]]>
June 9, 2009 at 2:18 pm |
hi,
i wanted to write data in a exisiting xml file.
Please suggets
June 12, 2009 at 6:09 am |
Hi Ravindra,
plz follow the link below about your question, and note the second comment on the post.
http://flexonblog.wordpress.com/2008/09/30/generate-xml-data-dynamically-in-flex-reloaded/
regards,
kumar.
July 31, 2009 at 2:27 pm |
Thanks.
I got hit.
That makes my work done.
Mayur
September 29, 2009 at 8:01 am |
Hi Kumar,
I am using the same code what you are using for generating xml list.But the problem with me is that I have to generate bulk amount of data.I am running a for loop and inside that xml is getting generated based on the length of the array.
So for bulk amount of data its taking too much amount of time and application is getting hanged.
Is there any alternate way to generate xml in a fast way?Please tell me .