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
25FCKXml.prototype =
26{
27	LoadUrl : function( urlToCall )
28	{
29		this.Error = false ;
30
31		var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ;
32
33		if ( !oXmlHttp )
34		{
35			this.Error = true ;
36			return ;
37		}
38
39		oXmlHttp.open( "GET", urlToCall, false ) ;
40
41		oXmlHttp.send( null ) ;
42
43		if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
44			this.DOMDocument = oXmlHttp.responseXML ;
45		else if ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 )
46		{
47			this.DOMDocument = FCKTools.CreateXmlObject( 'DOMDocument' ) ;
48			this.DOMDocument.async = false ;
49			this.DOMDocument.resolveExternals = false ;
50			this.DOMDocument.loadXML( oXmlHttp.responseText ) ;
51		}
52		else
53		{
54			this.DOMDocument = null ;
55		}
56
57		if ( this.DOMDocument == null || this.DOMDocument.firstChild == null )
58		{
59			this.Error = true ;
60			if (window.confirm( 'Error loading "' + urlToCall + '"\r\nDo you want to see more info?' ) )
61				alert( 'URL requested: "' + urlToCall + '"\r\n' +
62							'Server response:\r\nStatus: ' + oXmlHttp.status + '\r\n' +
63							'Response text:\r\n' + oXmlHttp.responseText ) ;
64		}
65	},
66
67	SelectNodes : function( xpath, contextNode )
68	{
69		if ( this.Error )
70			return new Array() ;
71
72		if ( contextNode )
73			return contextNode.selectNodes( xpath ) ;
74		else
75			return this.DOMDocument.selectNodes( xpath ) ;
76	},
77
78	SelectSingleNode : function( xpath, contextNode )
79	{
80		if ( this.Error )
81			return null ;
82
83		if ( contextNode )
84			return contextNode.selectSingleNode( xpath ) ;
85		else
86			return this.DOMDocument.selectSingleNode( xpath ) ;
87	}
88} ;