create rss xml

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • caine

    create rss xml

    I'm currently working on creating the xml feed since I had data ready
    in my database after web data extraction. However, it has errors for
    this line:

    <xml version="1.0" encoding="ISO-8859-1">

    I was unable to solve this.

    <html>
    <head>
    <title>MMU RSS FEED</title>
    </head>
    <body>

    header("Content-type: application/xml");


    <xml version="1.0" encoding="ISO-8859-1">

    <rss version ="2.0">


    <channel>
    <title>MMU RSS FEED Today: <?php echo date("D, d-M-Y H:i:s")?></
    title>
    <link>http://bulletin.mmu.ed u.my/</link>
    <description>MM U RSS FEED</description>
    <ttl>60<ttl>

    <?php

    //connect to database
    $db = mysql_connect(" localhost", "root", "") or die(mysql_error ());
    mysql_select_db ("bulletin", $db) or die(mysql_error ());

    $day = date("Y-n-j");

    //select queries
    $sql = "SELECT * FROM `bul_data` WHERE `DATE` LIKE '{$day}%' ORDER by
    `DEPARTMENT`";
    echo "sql=".$sql ;

    $res = mysql_query($sq l) or die(mysql_error ());

    if(mysql_num_ro ws($res)>0)
    {

    while($row=mysq l_fetch_assoc($ res))
    {
    $date = $row['DATE'];
    $title = $row['TITLE'];
    $department = $row['DEPARTMENT'];
    $link = $row['LINK'];

    //output to browser

    echo "<item>";
    echo "<title>$ti tle</title>";
    echo "<category>$dep artment</category>";
    echo "<link><a href=\"$link\"> $link</a></link>";
    echo "</item>";


    }

    echo "</table>";

    }

    ?>

    </channel>
    </rss>
    </body>
    </html>

  • Rik

    #2
    Re: create rss xml

    caine <thensiujing@gm ail.comwrote:
    I'm currently working on creating the xml feed since I had data ready
    in my database after web data extraction. However, it has errors for
    this line:
    >
    <xml version="1.0" encoding="ISO-8859-1">
    <?xml .... ?>
    --
    Rik Wasmus

    Comment

    • Curtis

      #3
      Re: create rss xml

      On Sun, 04 Feb 2007 06:41:16 -0800, Rik <luiheidsgoeroe @hotmail.comwro te:
      caine <thensiujing@gm ail.comwrote:
      >
      >I'm currently working on creating the xml feed since I had data ready
      >in my database after web data extraction. However, it has errors for
      >this line:
      >>
      ><xml version="1.0" encoding="ISO-8859-1">
      >
      <?xml .... ?>
      Since it's within a PHP document, you'd have to echo it, in case short
      tags start trying to process the contents of the declaration:

      echo '<?xml ... ?>';

      --
      Curtis, http://dyersweb.com

      Comment

      • caine

        #4
        Re: create rss xml

        <?xml .... ?>
        echo '<?xml ... ?>';
        Both these don't work as well. I tried with <?xml version="1.0"
        standalone="yes "?also failed.

        I'm saving this as .php file. Or could it be problem with setting or
        anything else?


        Caine

        Comment

        • Rik

          #5
          Re: create rss xml

          caine <thensiujing@gm ail.comwrote:
          <?xml .... ?>
          >
          >echo '<?xml ... ?>';
          >
          Both these don't work as well. I tried with <?xml version="1.0"
          standalone="yes "?also failed.
          >
          I'm saving this as .php file. Or could it be problem with setting or
          anything else?
          Disable short_open_tags .

          --
          Rik Wasmus

          Comment

          • Curtis

            #6
            Re: create rss xml

            On Sun, 04 Feb 2007 23:53:57 -0800, caine <thensiujing@gm ail.comwrote:
            <?xml .... ?>
            >
            >echo '<?xml ... ?>';
            >
            Both these don't work as well. I tried with <?xml version="1.0"
            standalone="yes "?also failed.
            >
            I'm saving this as .php file. Or could it be problem with setting or
            anything else?
            >
            >
            Caine
            >
            In what way is it not working? PHP error? XML parse error? If so, post the
            exact error you're getting.

            Also, maybe releated, on the line with "<title>", you have an echo
            statement in your document that isn't terminated by a semi-colon.

            --
            Curtis, http://dyersweb.com

            Comment

            • Jerry Stuckle

              #7
              Re: create rss xml

              Caine,

              Some interspaced comments. Probably not all of the errors, but it
              should give you a start.

              caine wrote:
              I'm currently working on creating the xml feed since I had data ready
              in my database after web data extraction. However, it has errors for
              this line:
              >
              <xml version="1.0" encoding="ISO-8859-1">
              >
              I was unable to solve this.
              >
              <html>
              <head>
              <title>MMU RSS FEED</title>
              </head>
              <body>
              >
              header("Content-type: application/xml");
              >
              Is this supposed to be a PHP statement? If so, it won't work here.

              It must be within <?php ... ?tags, and must appear before any output
              (including the <htmltag, any whitespace, etc.).
              >
              <xml version="1.0" encoding="ISO-8859-1">
              >
              Should be <?xml ...?>.
              <rss version ="2.0">
              >
              >
              <channel>
              <title>MMU RSS FEED Today: <?php echo date("D, d-M-Y H:i:s")?></
              title>
              Needs semicolon at the end of the PHP statement.
              <link>http://bulletin.mmu.ed u.my/</link>
              <description>MM U RSS FEED</description>
              <ttl>60<ttl>
              >
              Should be <ttl>60</ttl>
              <?php
              >
              //connect to database
              $db = mysql_connect(" localhost", "root", "") or die(mysql_error ());
              VERY BAD idea to connect with "root", especially with no password.
              Major security vulnerability.
              mysql_select_db ("bulletin", $db) or die(mysql_error ());
              >
              $day = date("Y-n-j");
              >
              //select queries
              $sql = "SELECT * FROM `bul_data` WHERE `DATE` LIKE '{$day}%' ORDER by
              `DEPARTMENT`";
              echo "sql=".$sql ;
              >
              $res = mysql_query($sq l) or die(mysql_error ());
              >
              if(mysql_num_ro ws($res)>0)
              {
              >
              while($row=mysq l_fetch_assoc($ res))
              {
              $date = $row['DATE'];
              $title = $row['TITLE'];
              $department = $row['DEPARTMENT'];
              $link = $row['LINK'];
              >
              //output to browser
              >
              echo "<item>";
              echo "<title>$ti tle</title>";
              echo "<category>$dep artment</category>";
              echo "<link><a href=\"$link\"> $link</a></link>";
              echo "</item>";
              >
              >
              }
              >
              echo "</table>";
              >
              }
              >
              ?>
              >
              </channel>
              </rss>
              </body>
              </html>
              >

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • caine

                #8
                Re: create rss xml

                The error statement i got is :

                Parse error: parse error, expecting `','' or `';'' in C:\Program Files
                \xampp\htdocs\p hprss.php on line 12

                for this line : echo "<?xml version="1.0" standalone="yes "?>";
                doesn't work.

                I had updated these lines:

                <?php

                header ("Content-Type: text/xml; charset=iso-8859-1");


                echo "<?xml version="1.0" standalone="yes "?>";

                echo "<rss version ="2.0">";


                echo "<channel>" ;
                echo "<title>MMU RSS FEED Today: date("D, d-M-Y H:i:s")</title>";
                echo "<link>http ://bulletin.mmu.ed u.my/</link>";
                echo "<description>M MU RSS FEED</description>";



                Comment

                • Jerry Stuckle

                  #9
                  Re: create rss xml

                  caine wrote:
                  The error statement i got is :
                  >
                  Parse error: parse error, expecting `','' or `';'' in C:\Program Files
                  \xampp\htdocs\p hprss.php on line 12
                  >
                  for this line : echo "<?xml version="1.0" standalone="yes "?>";
                  doesn't work.
                  >
                  echo "<?xml version=\"1.0\" standalone=\"ye s\"?>";

                  Or

                  echo '<?xml version="1.0" standalone="yes "?>'
                  ;
                  I had updated these lines:
                  >
                  <?php
                  >
                  header ("Content-Type: text/xml; charset=iso-8859-1");
                  >
                  >
                  echo "<?xml version="1.0" standalone="yes "?>";
                  >
                  echo "<rss version ="2.0">";
                  >
                  >
                  echo "<channel>" ;
                  echo "<title>MMU RSS FEED Today: date("D, d-M-Y H:i:s")</title>";
                  echo "<link>http ://bulletin.mmu.ed u.my/</link>";
                  echo "<description>M MU RSS FEED</description>";
                  >
                  >
                  >

                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • caine

                    #10
                    Re: create rss xml

                    echo "<?xmlversion=\ "1.0\" standalone=\"ye s\"?>";
                    >
                    Or
                    >
                    echo '<?xmlversion=" 1.0" standalone="yes "?>'
                    Not working again. Got the error statement like this:

                    XML Parsing Error: xml declaration not at start of external entity
                    Location: http://localhost/phprss.php
                    Line Number 7, Column 1: <?xml version="1.0" standalone="yes "?>
                    ^

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: create rss xml

                      caine wrote:
                      >echo "<?xmlversion=\ "1.0\" standalone=\"ye s\"?>";
                      >>
                      >Or
                      >>
                      >echo '<?xmlversion=" 1.0" standalone="yes "?>'
                      >
                      Not working again. Got the error statement like this:
                      >
                      XML Parsing Error: xml declaration not at start of external entity
                      Location: http://localhost/phprss.php
                      Line Number 7, Column 1: <?xml version="1.0" standalone="yes "?>
                      ^
                      >
                      Did you look at the error message? It says this isn't at the start. It
                      even tells you it's on line 7.

                      Check your XML spec. This must be the first thing in it.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Satya

                        #12
                        Re: create rss xml

                        On Feb 9, 8:56 am, "caine" <thensiuj...@gm ail.comwrote:
                        echo "<?xmlversion=\ "1.0\" standalone=\"ye s\"?>";
                        >
                        Or
                        >
                        echo '<?xmlversion=" 1.0" standalone="yes "?>'
                        >
                        Not working again. Got the error statement like this:
                        >
                        XML Parsing Error: xml declaration not at start of external entity
                        Location:http://localhost/phprss.php
                        Line Number 7, Column 1: <?xml version="1.0" standalone="yes "?>
                        ^
                        -------------------
                        I will suggest these changes in your script:

                        First of all you will change <xml ... to <?xml ... >.
                        Second may be short tag will create problem.
                        So for above line do something like this: echo '<?xml ....>';
                        and you are using header() below lot of html. Use header at top or use
                        ob_start(); at top.
                        I think you do not need <html>, <head>, <title>, <body>, etc. all
                        above header() line. So remove all these from bottom of the file.

                        Comment

                        Working...