Log in

View Full Version : Including XML pages in php



pssparkman
03-31-2008, 06:57 PM
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 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.

Parse error: parse error, unexpected 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:

<?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.

Zachary8222
03-31-2008, 07:20 PM
Well its very simple you just need to fix it to this:


<?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 (http://w3schools.com/php/php_xml_parser_expat.asp) tutorial.

pssparkman
03-31-2008, 09:48 PM
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?

Zachary8222
04-01-2008, 02:05 PM
Well look at the w3schools example, modify the script to parse it, and modify yourr xml if needed. Its actually pretty simple.