> I think you just need a root node.

No way. Your first example traces true just because there is only one
pg_name attribute.

Consider this:

var xmlData:XML = <root>
                                 <PAGE
pg_name='index'><DETAILS>page</DETAILS></PAGE>
                                 <PAGE
pg_name='contact'><DETAILS>page</DETAILS></PAGE>
                               </root>;
trace(xmldata.pa...@pg_name.tostring() == "index"); // false because
it evaluates as indexcontract
-- 
Kenneth Kawamoto
http://www.materiaprima.co.uk/


On 5 May 2010 17:49, Mattheis, Erik (MIN - WSW)
<ematth...@webershandwick.com> wrote:
> I think you just need a root node.
>
> var xmlData:XML = new XML (<root><PAGE 
> pg_name='index'><DETAILS>page</DETAILS> </PAGE></root>);
> trace(xmldata.pa...@pg_name.tostring() == "index"); // true
>
> var xmlData:XML = new XML (<PAGE pg_name='index'><DETAILS>page<DETAILS> 
> </PAGE>);
> trace(xmldata.pa...@pg_name.tostring() == "index"); // false
>
> _ _ _
> Erik Mattheis
> Senior Web Developer
> Minneapolis
> T  952 346 6610
> C 612 377 2272
>
> Weber Shandwick
> Advocacy starts here.
>
> PRWeek Global Agency Report Card 2009 - Gold Medal Winner
> The Holmes Report Global Agency of the Year
> PR News Agency of the Year
>
>
> -----Original Message-----
> From: flashcoders-boun...@chattyfig.figleaf.com 
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Singleton
> Sent: Wednesday, May 05, 2010 11:03 AM
> To: Flash Coders List
> Subject: Re: [Flashcoders] XML Question
>
> ----- Original Message ----
>
>> From: jonathan howe <jonathangh...@gmail.com>
>> To: Flash Coders List <flashcoders@chattyfig.figleaf.com>
>> Sent: Wed, May 5, 2010 11:23:25 AM
>> Subject: Re: [Flashcoders] XML Question
>>
>> You forgot your break; statements, sir.
>
> You're right, however it makes no difference in the outcome. It still 
> defaults to the default:
>
>        function completeXMLListener(e:Event):void
>        {
>            var xmlData:XML = XML (e.target.data);
>            trace(xmldata.pa...@pg_name.tostring())
>            switch (xmldata.pa...@pg_name.tostring())
>            {
>                case "index":
>                    pageDetails = xmlData.PAGE.DETAILS.toString();
>                    break;
>                case "contact":
>                    pageDetails = xmlData.PAGE.DETAILS.toString();
>                    break;
>                default:
>                    pageDetails = xmlData.PAGE.DETAILS.toString();
>                    trace(pageDetails);
>                    break;
>            }
>            MyTextBlock();
>        }
>
> and that is not what I want. I just put a couple of traces in the other cases 
> and they didn't fire. Please explain.
> TIA.
> John
>
> On Wed, May 5, 2010 at 11:12 AM,
>> John Singleton
> <
>> href="mailto:johnsingleton...@yahoo.com";>johnsingleton...@yahoo.com>wrote:
>
>>
>> ----- Original Message ----
>>
>> > From: allandt bik-elliott (
>> target="_blank" href="http://thefieldcomic.com";>thefieldcomic.com) <
>> ymailto="mailto:alla...@gmail.com";
>> href="mailto:alla...@gmail.com";>alla...@gmail.com>
>> >
>>
>> > i'd also recommend having a root node and an xml type declaration
>> at
>> > the start
>>
>> Right. Ok, here's my revised
>> code:
>>
>> <?xml version="1.0"?>
>>
>> <SITE>
>>  <PAGE pg_name='index'>
>>
>> <DETAILS>This is some more of the home page.</DETAILS>
>>
>> </PAGE>
>>  <PAGE pg_name='contact'>
>>
>> <DETAILS>This is some more of the contact
>> page.</DETAILS>
>>  </PAGE>
>>
>> </SITE>
>>
>>        function
>> completeXMLListener(e:Event):void
>>
>> {
>>            var xmlData:XML = XML
>> (e.target.data);
>>            trace(
>> ymailto="mailto:xmldata.pa...@pg_name.tostring";
>> href="mailto:xmldata.pa...@pg_name.tostring";>xmldata.pa...@pg_name.tostring())
>>
>>           switch (
>> ymailto="mailto:xmldata.pa...@pg_name.tostring";
>> href="mailto:xmldata.pa...@pg_name.tostring";>xmldata.pa...@pg_name.tostring())
>>
>>           {
>>
>>       case "index":
>>
>>           pageDetails =
>> xmlData.PAGE.DETAILS.toString();
>>
>>       case "contact":
>>
>>           pageDetails =
>> xmlData.PAGE.DETAILS.toString();
>>
>>       default:
>>
>>         pageDetails =
>> xmlData.PAGE.DETAILS.toString();
>>
>>           trace(pageDetails);
>>
>>         }
>>
>> MyTextBlock();
>>        }
>>
>> The first
>> trace nicely prints out what I would expect (I think, should have
>> been
>> on two lines):
>>
>> indexcontact
>>
>> The second trace
>> also prints:
>>
>> <DETAILS>This is some more of the home
>> page.</DETAILS>
>> <DETAILS>This is some more of the contact
>> page.</DETAILS>
>>
>> indicating, of course, that the default is
>> firing. Why?
>> TIA,
>> John

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to