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