SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: xml parse error

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xml parse error

    hi

    I am new to xml.

    I am trying to generate the xml file by looping through records from database. It is working fine. But if the data field is having
    any special character like & it is giving error xml parse error.

    I came to know that we can use CDATA to avoid it.

    please let me know how to use CDATA


    print("<cell>");
    print($row['pickup_addr']); //value for internal code
    print("</cell>");

    on this I want to use CDATA

    please help me out

    Thanks

    MD.Samiuddin

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your reply

    I checked the link. But it is not there what i am looking for

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A CDATA section starts with "<![CDATA[" and ends with "]]>". You can use one of the following examples.
    PHP Code:
    echo "<cell><![CDATA[" $row['pickup_addr'] . "]]></cell>"

    PHP Code:
    function cdata($s)
    {
            return 
    "<![CDATA[" $s "]]>";
    }

    echo 
    "<cell>" cdata($row['pickup_addr']) . "</cell>"


Bookmarks

Posting Permissions

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