February 17, 200818 yr Hello, I've just started learning xml however I'm slightly confused on something. With XML is it possible to have an xml document which holds some data then on a section of a xhtml web page the data from the xml document is displayed and styled? All the tutorials I'm finding seem to suggest that you only display the information in the xml document via the xml document and not through the external xhtml web page? Cheers.
February 17, 200818 yr Hi there, XML is mainly a data transfer language, meaning that it is used to send data in an easy to parse and understand way. You can use languages like XSLT (XLST?) to transform the document, and ultra-modern browsers can use CSS styling on non-standard elements, so you potentially style an XML document. For me, I use XML as the method to return data in an AJAX request, so, for example in my latest project I request the backend file with this query: GET backend.php?request=fileInfo&file=readme.txt&dir=./ The backend file returns XML something like this: <root> <fileInfo> <name>readme.txt</name> <size>326 bytes</size> <type>text</type> </fileInfo> </root> The Javascript (jQuery as usual) then parses this like any other XML based tech (like XHTML) and inserts it into the correct place in the page. Many API's (such as the Google APIs) return data in a similiar way, although they tend to be standardised to a sub-set like JSON and SOAP (google them, boring but useful) as it is easily parsed by PHP and Javascript. by the way, take a look in the PHP Tutorials here, there is a nice function for Array to XML.
Create an account or sign in to comment