I agree - XML is the way to go on this one... Perhaps something along
these lines is what you are looking for. Process each node you are
expecting in a switch - I externalized the parsing of the attributes
because they appeared to be the same across elements, but you could just
inline that for each loop in your switch to apply specific processing to
each type of node you are expecting.
var input:XML = <root><name color="ffffff" size="20" /><address
color="ff0000" size="16" /></root>;
for each (var node:XML in input.children())
{
switch (node.localName())
{
case "name":
trace("Some specific name processing");
parseAttributes(node);
break;
case "address":
trace("Some specific address processing");
parseAttributes(node);
break;
default:
throw new Error("Unidentified element: " +
node.localName());
}
}
private function parseAttributes(node:XML):void
{
for each (var att:XML in node.attributes())
{
trace(att.localName() + ": " + att.valueOf());
}
}
HTH,
Ryan
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Maciek Sakrejda
Sent: Monday, November 17, 2008 12:13 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Regular Expressions?
As a String? You *should* be able to use the top-level XMLList()
function to turn it into an XMLList (note, untested; should be close):
var foo:String = <name color="ffffff" size="16" /><address
color="000000" size="20" align="left" /><phone ... etc />;
var fooList:XMLList = new XMLList(foo);
Then just iterate over it. I would investigate the XML/XMLList API docs,
because your data will be much easier to work with as XML (since it is
XML) than using regular expressions, especially in terms of maintenance
and robustness.
--
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com
-----Original Message-----
From: tchredeemed <[EMAIL PROTECTED] <mailto:apthorp%40liberty.edu> >
Reply-To: [email protected]
<mailto:flexcoders%40yahoogroups.com>
To: [email protected] <mailto:flexcoders%40yahoogroups.com>
Subject: [flexcoders] Re: Regular Expressions?
Date: Mon, 17 Nov 2008 17:30:41 -0000
one problem:
It comes back like this:
<name color="ffffff" size="16" /><address color="000000" size="20"
align="left" /><phone ... etc />
So, how would I separate them by the node that I am currently working
with?
This message is private and confidential. If you have received it in error,
please notify the sender and remove it from your system.