Hi all…
I am running an xml file, containing php, through my php interpreter… but there is a parsing error… the error occurs on the very first line, regardless of what that is, either <?xml or <?php. I think it has to do with the <? portion of the xml tag as the php interpreter gets confused, but Im not sure. Even if my xml document contains no php, running it through the parser still causes the same problem, so I know it has nothing to do with my php coding skills. And the xml file works properly without using the parser, so I know my xml is correctly written. This has everything to do with the php parser and how it interprets xml. Does anyone know whats wrong… or even if running an xml file through a php parser is even possible.
why are you running an xml file through a php parser?[/QUOTE]Good question. There are good reasons but I'd like to here yours. By the way just echo the first line of your xml file.
[code=php]// remove this
<?xml version="1.0" encoding="iso-8859-1"?>
// replace with this
<?php echo '<?xml version="1.0" encoding="iso-8859-1"?>' ?>[/code]
Good question. There are good reasons but I'd like to here yours. By the way just echo the first line of your xml file.[/QUOTE]
but why would you run an xml only document through a php parser?[/QUOTE]It actually would have a negative effect. It would override Apache's default behaviour of sending 304 output for repeat requests on non-updated pages (wasting bandwidth). It also unnecessarily increases server load.
Scratch that, I dont mind discussing the "whys?," in fact I would like to, but not at the cost of dumping my initial question.[/QUOTE]Since your initial question has been answered by Nogdog and myself what additional information do you require as to '[I]how[/I]' to do it? As to the '[I]why[/I]' you wish to do it, I don't see why you don't just explain '[I]why[/I]' to those who are interested. In an earlier post you said you are doing this because '[I]you are trying to learn[/I]', well trying to suppress further discussion is not going to help that cause now is it?
[code=php]
<?php
header("Content-Type: application/xml; charset=ISO-8859-1");
echo '<?xml.......>';
// etc.....
?>
[/code]
You probably have[url=http://www.php.net/manual/en/ini.core.php#ini.short-open-tag]short open tags[/url] enabled on your PHP installation. Therefore, the PHP parser interprets [b]<?xml[/b] as two things: [b]<?[/b] as "start PHP code" followed by [b]xml[/b] as an undefined constant, likely generating a PHP syntax error. Thus the need to echo the <?xml tag from within your PHP code.[/QUOTE]
0.1.9 — BETA 6.16