1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
4 *
5 * == BEGIN LICENSE ==
6 *
7 * Licensed under the terms of any of the following licenses at your
8 * choice:
9 *
10 *  - GNU General Public License Version 2 or later (the "GPL")
11 *    http://www.gnu.org/licenses/gpl.html
12 *
13 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14 *    http://www.gnu.org/licenses/lgpl.html
15 *
16 *  - Mozilla Public License Version 1.1 or later (the "MPL")
17 *    http://www.mozilla.org/MPL/MPL-1.1.html
18 *
19 * == END LICENSE ==
20 *
21 * FCKXml Class: class to load and manipulate XML files.
22 * (IE specific implementation)
23 */
24
25var FCKXml = function()
26{
27	this.Error = false ;
28}
29
30FCKXml.prototype.LoadUrl = function( urlToCall )
31{
32	this.Error = false ;
33
34	var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ;
35
36	if ( !oXmlHttp )
37	{
38		this.Error = true ;
39		return ;
40	}
41
42	oXmlHttp.open( "GET", urlToCall, false ) ;
43
44	oXmlHttp.send( null ) ;
45
46	if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
47		this.DOMDocument = oXmlHttp.responseXML ;
48	else if ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 )
49	{
50		this.DOMDocument = FCKTools.CreateXmlObject( 'DOMDocument' ) ;
51		this.DOMDocument.async = false ;
52		this.DOMDocument.resolveExternals = false ;
53		this.DOMDocument.loadXML( oXmlHttp.responseText ) ;
54	}
55	else
56	{
57		this.DOMDocument = null ;
58	}
59
60	if ( this.DOMDocument == null || this.DOMDocument.firstChild == null )
61	{
62		this.Error = true ;
63		if (window.confirm( 'Error loading "' + urlToCall + '"\r\nDo you want to see more info?' ) )
64			alert( 'URL requested: "' + urlToCall + '"\r\n' +
65						'Server response:\r\nStatus: ' + oXmlHttp.status + '\r\n' +
66						'Response text:\r\n' + oXmlHttp.responseText ) ;
67	}
68}
69
70FCKXml.prototype.SelectNodes = function( xpath, contextNode )
71{
72	if ( this.Error )
73		return new Array() ;
74
75	if ( contextNode )
76		return contextNode.selectNodes( xpath ) ;
77	else
78		return this.DOMDocument.selectNodes( xpath ) ;
79}
80
81FCKXml.prototype.SelectSingleNode = function( xpath, contextNode )
82{
83	if ( this.Error )
84		return null ;
85
86	if ( contextNode )
87		return contextNode.selectSingleNode( xpath ) ;
88	else
89		return this.DOMDocument.selectSingleNode( xpath ) ;
90}