Xml.parse and CDATA on PHP

88 views
Skip to first unread message

Jean-Baptiste Richardet

unread,
Jun 2, 2014, 10:15:47 AM6/2/14
to haxe...@googlegroups.com
Hi,

I'm using Xml.parse to parse a XML/Excel file (attached here) used a locale.
My problem is line 117
<Cell ss:StyleID="s65"><Data ss:Type="String" x:Ticked="1">Titre de l'épisode</Data></Cell>

This line is automatically parse as:
<Cell ss:StyleID="s65"><Data ss:Type="String" x:Ticked="1"><![CDATA[Titre de l']]><![CDATA[épisode]]></Data></Cell>

when I'm compiling for PHP. I was previously targeting Flash, and this never occurred.

Is there an option to disable this behavior? Should I escape the ', or the 'é'?

Thanks,

Jb Richardet
goodExcelLocale.xml

Andreas Mokros

unread,
Jun 2, 2014, 2:42:18 PM6/2/14
to haxe...@googlegroups.com
Hi.

On Mon, 2 Jun 2014 07:15:46 -0700 (PDT)
Jean-Baptiste Richardet <jeanbaptist...@gmail.com> wrote:
> This line is automatically parse as:
> <Cell ss:StyleID="s65"><Data ss:Type="String"
> x:Ticked="1"><![CDATA[Titre de l']]><![CDATA[épisode]]></Data></Cell>
> when I'm compiling for PHP.

There's an old issue from me about that:
https://github.com/HaxeFoundation/haxe/issues/2299

> Is there an option to disable this behavior? Should I escape the ',
> or the 'é'?

I think the é is the problem and my workaround was to replace
htmlentities with htmlspecialchars in __character_data_handler
function...

--
Mockey

Jean-Baptiste Richardet

unread,
Jun 2, 2014, 2:46:56 PM6/2/14
to haxe...@googlegroups.com
Actually, the ' is a problem too. Can you point me to this __character_data_handler function so I can try your workaround?

The milestone for the fix is 3.2, I hope it will come soon.

Thank you

Andreas Mokros

unread,
Jun 2, 2014, 3:53:02 PM6/2/14
to haxe...@googlegroups.com
Hi.

On Mon, 2 Jun 2014 11:46:56 -0700 (PDT)
Jean-Baptiste Richardet <jeanbaptist...@gmail.com> wrote:
> Actually, the ' is a problem too. Can you point me to this
> __character_data_handler function so I can try your workaround?

It's in std/php/_std/Xml.hx, line 68. Try replacing "htmlentities" with
"htmlspecialchars". Maybe that helps. I don't remember...

> The milestone for the fix is 3.2, I hope it will come soon.

I don't think so. I use PHP's native XML functions atm, when working
with PHP and XML.

I would have submitted a pull request, but as I said in the issue I
don't quite understand the parsing that's done here:
Why does __character_data_handler encode entities and create CDATA-nodes
at all?
And why is the function that actually encodes entities called
__decodeent?
And so on...

--
Mockey

David Elahee

unread,
Jun 3, 2014, 12:39:46 AM6/3/14
to haxe...@googlegroups.com

Please ping the Php issue with your cases, it will help everyone.

Thank you both ;)

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages