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 4 of 4
  1. #1
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts

    encoding for sitmap

    I am dynamically creating a sitemap.xml to help google index my pages correctly. Because the sitemap will be generated by PHP and it has to be encoded in UTF-8. Is there any way i can get my PHP script to write the file in UTF-8
    You can not say you know how to do something, until you can teach it to someone else.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Don't you just have your PHP script write something like this to a file?

    This example is an XML for MP3 playlist, but the idea is that the first
    line defines the encoding. The code itself is just a text file.

    <?xml version="1.0" encoding="utf-8"?>
    <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xml:lang="EN" version="2.0">
    <channel>
    ...
    Everything in here
    ...
    </channel></rss>


    When that text file is read by the browser ... that's when it's encoded based on utf-8.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Surley the text in the file has to be UTF-8
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Quote Originally Posted by timgolding View Post
    Surley the text in the file has to be UTF-8
    ???

    a text file is a text file is a text file ...

    When a server opens a text file and sends it to a user's browser,
    it is encoded by whatever encoding instructions it is given ...

    See this site:
    http://www.xml-sitemaps.com/

    Create your own XML sitemap for your own site, then view the XML file.
    Notice the very top line.

    <?xml version="1.0" encoding="UTF-8" ?>
    - <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    - <url>


    The XML file itself is just a text file (ASCII).

    Maybe you're talking about something I've never heard of?
    Does anyone else know what I'm not seeing here?


  •  

    Posting Permissions

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