Skip to main content
Inspiring
February 23, 2009
Question

XML won't validate

  • February 23, 2009
  • 9 replies
  • 1796 views
Hi folks,

It doesnt like the folling xml, I keep getting the errors:

Can anyone help? I thought the special chars ’ were valid??

Line File name: Nonexistent
2 Column: 23
Error: Can not find declaration of element 'xml'.
Error Position:

<xml version="1.0">



Line File name: Nonexistent
105 Column: 156
Error: Entity "rsquo" was referenced, but not declared.
Error Position:

...ave announced that Sandwell&rsquo;s Agewell

    This topic has been closed for replies.

    9 replies

    matthiscoAuthor
    Inspiring
    February 25, 2009
    Thanks again for your replies folks.

    I have this working to an extent, but its very touch and go, its still doesnt like certain charactors.

    The xml document is created from a database query, which holds user generated content. Ideally I would like to store the data in the xml document without any formatting, but I need a least paragraph tags.

    Can you guys think of a way aorund this?

    Is there a way I can store the formatting in xml?

    Thanks again

    Participating Frequently
    February 25, 2009
    Wrap everything being pulled from the database in an XMLFormat() function. That way, any special characters will be escaped.
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_t-z_20.html#139554
    February 24, 2009
    <?xml version="1.0" mencoding="UTF-8" ?>

    What's a "memcoding"?

    ;-)

    one of the easiest ways to spot these sort of thngs is to browse to the XML file in a browser. Firefox pointed the exact location of the problem instantly.

    --
    Adam

    matthiscoAuthor
    Inspiring
    February 24, 2009
    Its throwing this error now:

    Line File name: Nonexistent
    1 Column: 52
    Error: Can not find declaration of element 'items'.
    Error Position:

    <?xml version="1.0" encoding="ISO-8859-1"?><items>
    matthiscoAuthor
    Inspiring
    February 24, 2009
    Thanks for all your help.

    I've done your suggestions but still getting problems, code attached
    Known Participant
    February 24, 2009
    Sounds to me like you have some whitespace before your XML declaration line. There has to be NO space at all. So make sure you don't have a carriage return or anything like that in your code that's adding space.
    Participating Frequently
    February 23, 2009
    Looks like there's funky characters in the title. I'm not sure if that is causing CFs XML parser to get upset.

    To play it safe, wrap all your text with a CDATA block.

    E.g.:
    <title><![CDATA[ this is my title ]]></title>
    <summary><![CDATA[ .... ]]></summary>
    etc...

    Participating Frequently
    February 23, 2009
    How are you using this XML? Post the code that is throwing this error, please.
    matthiscoAuthor
    Inspiring
    February 23, 2009
    Thnaks for your reply.

    I've changed that but now get the error, any ideas?

    Line File name: Nonexistent
    2 Column: 7
    Error: Processing instruction target matching "[xX][mM][lL]" is not allowed.
    Error Position:

    <?xml version="1.0" encoding="UTF-8" ?>
    Participating Frequently
    February 23, 2009
    Your XML declaration is wrong. You have this:
    <xml version="1.0">

    It should be this:
    <?xml version="1.0" encoding="UTF-8" ?>