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.
22
* (IE specific implementation)
25
var FCKXml = function()
30
FCKXml.GetAttribute = function( node, attName, defaultValue )
32
var attNode = node.attributes.getNamedItem( attName ) ;
33
return attNode ? attNode.value : defaultValue ;
37
* Transforms a XML element node in a JavaScript object. Attributes defined for
38
* the element will be available as properties, as long as child element
39
* nodes, but the later will generate arrays with property names prefixed with "$".
41
* For example, the following XML element:
43
* <SomeNode name="Test" key="2">
45
* <OtherLevel name="Level 3" />
48
* <AnotherChild price="499" />
51
* ... results in the following object:
77
FCKXml.TransformToObject = function( element )
84
var attributes = element.attributes ;
85
for ( var i = 0 ; i < attributes.length ; i++ )
87
var att = attributes[i] ;
88
obj[ att.name ] = att.value ;
91
var childNodes = element.childNodes ;
92
for ( i = 0 ; i < childNodes.length ; i++ )
94
var child = childNodes[i] ;
96
if ( child.nodeType == 1 )
98
var childName = '$' + child.nodeName ;
99
var childList = obj[ childName ] ;
101
childList = obj[ childName ] = [] ;
103
childList.push( this.TransformToObject( child ) ) ;