Results 1 to 4 of 4

Thread: Including XML pages in php

  1. #1
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Including XML pages in php

    I have a web page that I want to be able to include into a php page. The Xml page uses an xls page for it formating.

    I am using the following to include the page:
    PHP Code:
    <?php include 'squad.xml' ?>
    When trying to view the php page that I want the xml page to be included in, I get the following message when I try to view it.
    PHP Code:
    Parse errorparse errorunexpected T_STRING in /home/content/T/m/W/Tm ... on Line 1 
    The following code is located at the top of the xml page starting at Line 1:
    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE squad SYSTEM "squad.dtd">
    <?xml-stylesheet href="squad.xsl" type="text/xsl"?>

    I can view the xml page on its own just fine, but would like to include it into an existing web page.Any help would be appreciated.

  2. #2
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well its very simple you just need to fix it to this:

    PHP Code:
     <?php include 'squad.xml'?>
    Now that will only include the document, but it will not parse it. If you are trying to parse it look at this tutorial.

  3. #3
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh...my bad. I did have that ; in the code, just forgot it when I typed it in the above post.

    What do you mean by parse it? What does it do?



    I tried to parse it with a code found on the net, and it did show the xml page, but didn't show it in the format it should be shown in (using an xls file). Any suggestions?
    Last edited by pssparkman; 03-31-2008 at 10:42 PM.

  4. #4
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well look at the w3schools example, modify the script to parse it, and modify yourr xml if needed. Its actually pretty simple.

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
  •