#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2009
    Posts
    58
    Rep Power
    6

    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&quot; 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
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    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.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    191
    Rep Power
    49
    at first look at your editor which generated the xml file
    which encoding the editor used.

    with decodeunicode
    search your sign
    example Euro sign &#x20AC;

    then use in xml file
    Code:
    <field name="euro">The Euro Sign &#x20AC;</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

IMN logo majestic logo threadwatch logo seochat tools logo