2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * FCKXml Class: class to load and manipulate XML files.
\r
26 LoadUrl : function( urlToCall )
\r
28 this.Error = false ;
\r
31 var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ;
\r
32 oXmlHttp.open( 'GET', urlToCall, false ) ;
\r
33 oXmlHttp.send( null ) ;
\r
35 if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 || ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 ) )
\r
37 oXml = oXmlHttp.responseXML ;
\r
38 // #1426: Fallback if responseXML isn't set for some
\r
39 // reason (e.g. improperly configured web server)
\r
41 oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
\r
48 // Try to access something on it.
\r
51 var test = oXml.firstChild ;
\r
55 // If document.domain has been changed (#123), we'll have a security
\r
56 // error at this point. The workaround here is parsing the responseText:
\r
57 // http://alexander.kirk.at/2006/07/27/firefox-15-xmlhttprequest-reqresponsexml-and-documentdomain/
\r
58 oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
\r
62 if ( !oXml || !oXml.firstChild )
\r
65 if ( window.confirm( 'Error loading "' + urlToCall + '" (HTTP Status: ' + oXmlHttp.status + ').\r\nDo you want to see the server response dump?' ) )
\r
66 alert( oXmlHttp.responseText ) ;
\r
69 this.DOMDocument = oXml ;
\r
72 SelectNodes : function( xpath, contextNode )
\r
75 return new Array() ;
\r
77 var aNodeArray = new Array();
\r
79 var xPathResult = this.DOMDocument.evaluate( xpath, contextNode ? contextNode : this.DOMDocument,
\r
80 this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
\r
83 var oNode = xPathResult.iterateNext() ;
\r
86 aNodeArray[aNodeArray.length] = oNode ;
\r
87 oNode = xPathResult.iterateNext();
\r
93 SelectSingleNode : function( xpath, contextNode )
\r
98 var xPathResult = this.DOMDocument.evaluate( xpath, contextNode ? contextNode : this.DOMDocument,
\r
99 this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
\r
101 if ( xPathResult && xPathResult.singleNodeValue )
\r
102 return xPathResult.singleNodeValue ;
\r