December 6th, 2010, 06:26 AM
-
XML 'CDATA' Error
Hi folk,
I m new to XML,
I tried making XML and got error in initial stage because of non-ascii char.
I searched on web and find CDATA to hide the data from parsing.
but this also dont help for me and I am not able to make the XML works.
below is my XML which creates the problem.
XML Code:
<?xml version="1.0"?>
<add>
<doc>
<field name="postid">342</field>
<field name="userid">501</field>
<field name="bucketid">3</field>
<field name="title"><![CDATA[Flirting with Apple ]]></field>
<field name="description"><![CDATA[As the title suggest, I'm kicking around the idea of purchasing an Apple computer. � Models in the the 13" MacBook Air, and the Mac Mini. . � There are some issues I do have. The whole internal battery high tech, but still.... � Anyways, I'd appreciate any feedback/comments on which way I should go. Thanks! � � � � � � ]]></field>
</doc>
</add>
Please help.
Thanks is advance
December 6th, 2010, 03:25 PM
-
Originally Posted by shariqnitt
CDATA to hide the data from parsing.
That's not quite what it does. There's two phases to "parsing" XML, if you will: 1) reading the characters, and 2) parsing it. A CDATA will only prevent #2 from happening (and even then, not all parsing); you still have to pass #1.
Set an encoding for your XML.
Code:
<?xml version="1.0" encoding="???"?>
The encoding can be whatever you want - popular choices are UTF-8 ("utf-8") and ISO 8859-1 ("iso-8859-1").
Once you've picked one, make sure everything in your XML is in that encoding.
December 7th, 2010, 05:14 AM
-
at first look at your editor which generated the xml file
which encoding the editor used.
with decodeunicode
search your sign
example Euro sign €
then use in xml file
Code:
<field name="euro">The Euro Sign €</field>
after &# used a small x to say is a hex number
so euro sign is display
Code:
<?xml version='1.0' encoding='unicode' ?>
<root>
<item>The Euro Sign €</item>
</root>
Helmut Hagemann Germany
fallen to the bottom of the facts?
I reach my hand and we go together
wer lesen und google kann ist klar im Vorteil
who read and google is able is clear in the advantage