View Full Version : Resolved How to load HTML as XML?

11-19-2008, 12:04 AM
Hi all,

I'm looking for a way to load an HTML file as XML. I have a almost-empty HTML file with a little PHP that generates the XML from a database.

Flash is able to read this file as XML just fine, but not JS. I'm using the Sarissa wrapper, and the code just stops when it tries to load said file. If I save the output as an XML file, Sarissa has no trouble. Does anyone know of another library or something that would enable me to do this?

Any tips greatly appreciated!

11-19-2008, 01:22 AM
I don't think that this is possible, but you can use XHTML. Extensible Hypertext Markup Language (I think). This treats the HTML file as XML. You have to know XHTML syntax to do this, though, and also you have to include a <!DOCTYPE> tag stating your HTML file is XHTML. This should do.


11-19-2008, 06:39 PM
So I need something like this, right?

<!DOCTYPE rootElement PUBLIC "PublicIdentifier" "URIreference">

What do I use for a PublicIndentifier and URIreference? I'm having no luck with Google. :(

11-19-2008, 10:05 PM

Good site: http://www.w3schools.com/tags/tag_DOCTYPE.asp

If you don't want to go there, use this:

Strict XHTML:

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

Transitional XHTML:

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

Frameset XHTML:

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

I'm pretty sure you can load XHTML files with AJAX/PHP/ASP etc. Look it up if you want.


11-20-2008, 06:56 PM
I read more into this, and you need to define your own doctypes for XML. There is a great article on it here:


Thanks for your input!