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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question AJAX: How Can I Ask XML Parser Stop Complaining?

    Hi,
    I am writing AJAX code to retrieve XML from server using PHP. It works most of the time. But once in a while, I encounter XML Parsing Error: not well-formed Error. Inside the XML returned from the server, there may be code that are not qualified as XHTML because it's older stuff, maybe that's why the parser is complaining and I don't plan to change these older stuff. As a result, I can't retrieve any xml from it. I don't really care about the not well-formed error because I am need only bits and pieces inside the xml and I don't care about the form.

    Is there a way to force the parser to return the Not well-formed XML, so that I can read what's inside the XML returned?

    Many thanks.

  • #2
    Regular Coder
    Join Date
    Jul 2005
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    I found the solution, just want to share with you guys.

    if you use php in server, use urlencode() to encode the html or whatever code that may potentially upset XML parser. Then in javascript, use decodeURIComponent to decode the stuff in xml back to html or whatever.

  • #3
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    the other way is to use CDATA sections which tell the XML parser to ignore everything within it.

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper


  •  

    Posting Permissions

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