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