FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


XML/XHTML header problem





boinsterman
I created a new XHTML document in editx (an XML editor, the free version), imported an existing php/html document into it, get the following error from http://worldthinker.frihost.org/codeexamples/asqltesting2.php :

Quote:
Parse error: syntax error, unexpected T_STRING in /home/boinster/domains/worldthinker.frihost.org/public_html/codeexamples/asqltesting2.php on line 1


in Opera 12.16 for Windows XP. I had thought that XHTML was simply a version of XML and should work fine like that.

The document's header was :

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- New document created with EditiX at Sun Dec 15 17:30:07 EST 2013 -->

<html xmlns="http://www.w3.org/1999/xhtml">


When I deleted

Code:
<?xml version="1.0" encoding="UTF-8"?>


the page worked fine, and I will likely keep it like that. The problem is that I hope to work extensively with XML in the near future and need a better understanding of headers in XML. Will it work fine with "filename.xml"? Is anyone else on Frihost working with XML, and do you have any examples of XML docs?

Thanks
Marcuzzo
OK, so when creating XHTML pages you don't need an XML header.

Code:
<?xml version="1.0" encoding="UTF-8"?>

is an XML header.
This has got nothing to do with XHTML.

when you use XML documents it is better to use it (in the XML document) but even then you can get away with leaving it out.

EDIT: as far as filenames go, you can use anything you like. XML is used for a lot of different reasons.


for more info on XML and how to use it I would suggest this link: http://www.w3schools.com/xml/
zacky
I totally agree with Marcuzzo said.

Anyway just for additional info, I think you got confuse in XHTML vs XML. There are lot of resources that you can read on web how they define it but for me the main difference is the structure and how you can use it. XML structure is Parent to Child Tree node while XHTML and its relatives does the same way except how you use it such as main view of your template.

Here is the full documentation and complete reference for you to learn:

HTML: https://developer.mozilla.org/en-US/docs/Web/HTML

XML: https://developer.mozilla.org/en-US/docs/XML

Hope you enjoy reading.
Peterssidan
The error you got is a PHP error. It sees <? as an opening PHP tag and tries to parse the text after it as PHP code.

If you still want the XML declaration you can turn off short_open_tag or simply output it from PHP.
Code:
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
boinsterman
Fixing the PHP error the way you described worked fine. Thanks, Peterssidan.

However, I probably will not include the xml header for xhtml docs. It does not seem to add any functionality or improve speed, and could lead to other errors in the future.

XML, HTML, and XHTML are all just versions of SGML, correct? Browsers have been programmed to interpret keywords standardized for the latter two, and CSS and XSLT can be used to interpret XML.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.