I’m wondering how I can parse XML documents returned by a search so that I can style them with CSS on a website. I’m assuming I need to turn the XML into xhtml some how first, and then style the elements accordingly. I need them to display xhtml.
Does anyone know the easiest way to go about this? I know styling straight XML with CSS is not good practice, which is why I’m thinking there must be a javascript solution.
Any insight would be great, thanks!
D
If you’re importing XML via AJAX then there are only a few key things you need to do…
1.) The parent-most element needs an XML namespace…
2.) Use W3C standard methods (appendChild, importNode, responseXML) and NOT proprietary Microsoft methods (innerHTML, responseText) or your application will be treated like notepad text instead of an actual application. Here is roughly what the code looks like…
By using the correct code you’ll have no problem styling imported XHTML. For a live demo visit my site in my profile and then at the top right click on site options.