Hey all,

Does anyone does the xml serialize uses attributes as a default rather
than tags/elements?  It would seem like it to me that XML data should
use tags rather than elements.

Take for example the following array (off the cakephp website):
Array
(
    [Baker] => Array
        (
            [0] => Array
                (
                    [name] => The Baker
                    [weight] => heavy
                )
            [1] => Array
                (
                    [name] => The Cook
                    [weight] => light-weight
                )
        )
)

CakePHP formats it by default like:
<baker>
     <baker name="The Baker" weight="heavy" />
     <baker name="The Cook" weight="light-weight" />
</baker>

You can also optionally format it using tags like so:
<baker>
    <baker>
        <name><![CDATA[The Baker]]></name>
        <weight><![CDATA[heavy]]></weight>
    </baker>
    <baker>
        <name><![CDATA[The Cook]]></name>
        <weight><![CDATA[light-weight]]></weight>
    </baker>
</baker>

The only problem with the second formatting is that all of the array
data is trapped in a CDATA.  CDATA is ignored by a XML parser.  It has
also been brought to my attention that attributes are also ignored by
many parsers or can cause issues with some XML parsers.  I'm not sure
if this is true or not.

I was told that the correct format should look more like this:
<baker>
    <baker>
        <name>The Baker</name>
        <weight>heavy</weight>
    </baker>
    <baker>
        <name>The Cook</name>
        <weight>light-weight</weight>
    </baker>
</baker>

Why does cake not do this by default?  Why also does cake not have the
option to use this format?

Thanks,
-Matt Brooks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to