| 1. |
Solve : XML learning experience a little painful? |
|
Answer» OK, I was going to include this in my RPG thread, but I'm not planning on using XML in my game (though I could if I needed to). So it doesn't belong in that thread. Besides, blending the topics of PHP and XML would be a disaster - PHP's confusing enough as is. Fun facts Simple, but I got sick of Hello World! every time I learned something new. Anyway, the output of http://127.0.0.1/test.xml: Quote <?xml version="1.0" encoding="ISO-8859-1" ?> Note the missing "" line in the online version, which renders fine in the file version. What causes this, and how may I get around it?Looks to me like your Apache installation isn't set up with knowledge of XML as a MIME type. Don't know where the config is on a Win install, so I may have to get back to you.Whoa, I found it and fixed it! I went to the conf folder with the intent of editing the httpd.conf file. However, I saw the file mime.types and edited it. I saw that pages that were html/htm had a double-tab, then the extension, like: Quote text/html html htm[/pre] but the xml one was blank. I double-tabbed over, typed "xml" and hit save. Now, I get this: Not very complicated, but it IS exactly what I wanted. I think I got lucky on this one. [edit]And I now have a use for IE: It's the only browser that shows XML code without clicking "View Source". [/edit]Yep, well done - that's the fix. I haven't investigated XML much beyond the theory, for the very reason you outline: lack of support/adoption. HTML+CSS+PHP+MySQL WORKS just fine for me at the moment.IMHO, XML would be good for PIECES of pages that require data storage, but it's not meant to be used to format an entire page. You could use it, for example, as a Web-based database. Of course, it shouldn't be used as the only content in a page. ***WARNING: IGNORE THE POST BELOW, IT'S THE RAMBLINGS OF A GUY WITH TOO MUCH TIME ON HIS HANDS*** The W3C is nice enough to provide a few ways to format XML. It suggests: CSS - I didn't know this, but you can actually fomat XML with Cascading Style Sheets. Curious. The W3C insists, however, that it is NOT the future of formatting XML. Funny, that - it's a way to bypass the problems encountered by using the future of XML parsing. JavaScript - The W3C doesn't provide an example, just mentions in an esoteric passage in their XML tuts that it's possible. Finally, it's possible, they say, to use the tag in an HTML. That's odd, the strangest application I've seen for it yet. I don't know what kind of support browsers offer. There are apparently multiple methods of synchronizing HTML with XML. Sorry if you already know this, but you said you didn't investigate it, so I thought I'd let you know just in case. [edit]I tested the parsing ability of FireFox 1.5, Opera 8.52, Internet Explorer 6.0, Netscape 8.1 and Mozilla 1.7.12. Here are the results: FireFox - parsed my XML correctly. Opera - was a total mess. Internet Explorer - parsed correctly. Mozilla - parsed correctly. Netscape - parsed correctly. (X)HTML appeared fine on 4 out of 5 major browsers tested. Mind, these are the latest versions, so I don't know about older ones. But this is a pretty good score. And if you don't rely on (H)XTML for the whole page, it should work for all of them.[/edit] [edit]I removed the XSL stylesheet and its reference in the XML file for testing on showing code. Same browsers tested. Results: FireFox - upon realizing that there was no stylesheet, showed the document tree as expected. It gave a message at the top specifying that it couldn't find a XSL page and would show the tree. Opera - again, total mess. Internet Explorer - showed document tree. Mozilla - showed document tree. Same message as FireFox. Netscape - showed document tree. Same message as FireFox and Mozilla. XML has FAIRLY good support nowadays - it's Opera that's falling behind the curve.[/edit] |
|