I recently upgraded the version of CakePHP in a project I work on to
version 1.2.5. Since then, it seems that the XML class is unable to
parse some XML strings correctly.
Here's the code:
$tmp_xml =& new XML($XMLFilename);
$tmp_xml = $tmp_xml->toArray(false);
The contents of the filename contained within $XMLFilename is:
<wpkg>
<host name="PE-TA-16" profile-id="Default" />
<host name="PE-TA-17" profile-id="Default" >
<profile id="NBSContract" />
</host>
<host name="PE-TA-SCWEB" profile-id="Default" />
<host name="PEI-100000A" profile-id="Default">
<profile id="Infoworks" />
</host>
<host name="PEI-2D100000A" profile-id="Default">
<profile id="Infoworks" />
</host>
<host name=".+" profile-id="Default" />
</wpkg>
The result of printing out (pr) $tmp_xml after the second line of code
is:
Array
(
[wpkg] => Array
(
[host] => Array
(
[0] => Array
(
[0] => Array
(
[name] => PE-TA-16
[profile-id] => Default
)
[1] => Array
(
[name] => PE-TA-17
[profile-id] => Default
[profile] => Array
(
[id] => NBSContract
)
)
)
[1] => Array
(
[name] => PE-TA-SCWEB
[profile-id] => Default
)
[2] => Array
(
[name] => .+
[profile-id] => Default
)
)
)
)
As you can see, not only are some of the XML nodes completely missing,
but the first two are actually grouped together in a sub-array for
some odd reason. I have even tried changing the "host" nodes with no
children to explicitly have ending tags, but it made no difference.
XML files with this same structure were parsed just fine prior to
1.2.5.
If I use toArray(true) or the old Set::reverse() method, it gets
worse: I only get the details (attributes and child data) for just a
single XML node. I saw a couple XML class bug fixes that were made for
1.2.5 that supposedly fixed this problem with not parsing children
correctly, but perhaps the fix wasn't foolproof enough.
Has anyone else ran into this problem and came up with a solution or
at least the root cause?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---