Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: xml help please

  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    xml help please

    I have an xml file that is uploaded to the database but if theres( & ) in there it wont upload and I get this error "parser error : Extra content at the end of the document"

    Code:
    <catalog>
    <product>
    <curl>www.company.com</curl>
    <title>test & testing</title>
    <description>testing & test</description>
    </product>
    </catalog>
    Thanks for your help

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by stebbi View Post
    I have an xml file that is uploaded to the database but if theres( & ) in there it wont upload and I get this error "parser error : Extra content at the end of the document"

    Code:
    <catalog>
    <product>
    <curl>www.company.com</curl>
    <title>test & testing</title>
    <description>testing & test</description>
    </product>
    </catalog>
    Thanks for your help
    replace & with &amp;

    a better solution but bloated in your case:
    Code:
    <description><![CDATA[testing & test]]></description>
    best regards

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks I need it to be in the code there will be clients uploading the file cant be sure they will use &amp; can I expect this problem with any other characters?

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by stebbi View Post
    Thanks I need it to be in the code there will be clients uploading the file cant be sure they will use &amp; can I expect this problem with any other characters?
    yes, any character which is not allowed in xml must be replace by it's entity, that means:
    Code:
    & -> &amp;
    < -> &lt;
    > -> &gt;
    ' -> &apos;
    " -> &quot;
    The alternative is to use CDATA sections. If the user upload the file I suggest to use a schema to validate it when they upload.

    My apologize that I didn't explay why in my previos replay.

    best regards

  • Users who have thanked oesxyl for this post:

    stebbi (04-09-2009)

  • #5
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,460
    Thanks
    1
    Thanked 23 Times in 21 Posts
    It's worth mentioning that the entities (as they're called) in oesyxl's post also work with HTML.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •