First of all, the example:
Advantages
Ease of use
The method allows embedding of XML display section into existing HTML page with minimal modifications of your code. In fact you should copy-paste 3 lines of code and place two files into your folder.Cross-browser
I've tested the code with Forefox 2, IE6 and IE7. All work nicely.Syntax highlighting
In the displayed XML, the content is highlighted based on it's meaning: node names, node content, attributes and their names. All this are easily controlled through the CSS file. Trust me, you need no knowledge of CSS to change the XML appearance.Collapsible
The XML display is dynamic. Your client can collapse and expand any node.Complete AJAX
The code is completely executed at the client's machine. First the web page is loaded and only after it, the shown XML is streamed and presented. Consequently, the LoadXML method can be executed at any time to reload executed another asynchronouse call to the server and to load the XML obtained as a result of that code. See Usage for more details.Usage
Embedding XML viewer into existing HTML code couldn't be simpler.
- First, place the two following files: one and two into some folder of your site.
-
Next, alter your HTML web page in the following way:
The only things you may want to change are the pathes to the css and the js files and the name of the xml file in the call to the LoadXML method. Enjoy.
If you use this script for debugging AJAX application, you may manually call LoadXML, LoadXMLDom or LoadXMLString functions. As first parameter, each of them receives ID of the HTML element (usually, div) intended to contain the displayed XML. Alternatively, you may send the HTML element DOM object itself, not its ID.
The second parameter differs depending on the function: LoadXML receives request to the server which will be executed asynchronously. LoadXMLDom receives DOM object containing arbitrary XML. Finally, LoadXMLString receives the string of the XML to be displayed.
Each of these functions returns true if they were successfully executed (notice, that LoadXML returns immediately after sending request to the server and does not know whther the call passed through).
Support:
And finally. You are most welcome to use the forum to post the questions, feature requests and cries for help you might have. Another option is a direct e-mail to me. I'll do my best to help.
