  | |  | Recursion woes | Recursion woes
2004-02-22 - By Iv
Back Hello Richard,
yep.
// source: proto.layer51.com/d.aspx?f=1098
// Ivan Dembicki
XMLNode.prototype.addProperty( "tabbedString ", function(t) {
var j, s, a, n = this.firstChild, f = arguments.callee;
while (n != undefined) {
if (n.nodeType != 3) {
a=n.attributes, s += " "+t+ " < "+n.nodeName; for (j in a) {s += " "+j+ "=\ " "+a[j]+ "\ " "; }
s += (n.firstChild ? " >\n "+f.call(n, t+ "\t ")+t+ " </ "+n.nodeName+ " >\n " : " / >\n ");
} else {
s += t+(n.toString() != n.nodeValue ? " <![CDATA[ "+n.nodeValue+ "]] > " : n.nodeValue)+ "\n ";
}
n = n.nextSibling;
}
return s;
}, null)
///////////////////////////////////////////////////
my_xml = new XML();
my_xml.load( "data.xml ");
my_xml._parent = this;
my_xml.ignoreWhite = true;
my_xml.onLoad = function(ok) {
if (!ok or this.status) {
return trace( "loaded: "+ok+ " valid: "+!this.staus);
}
var x = new XML( " <menu/ > ");
this._parent.toShort(x.firstChild, this.firstChild);
this._parent.short_xml = x;
trace( "rezult: ");
trace(x.tabbedString);
};
this.toShort = function(to_xml, in_xml) {
var fn = arguments.callee;
var i = 0, j = 0;
var nod, n, at, a = in_xml.childNodes, len = a.length;
for (i; i <len; i++) {
nod = a[i];
if (nod.nodeName == "PAGE ") {
to_xml.appendChild(new XMLNode(1, "PAGE "));
at = to_xml.lastChild.attributes;
at.label = nod.attributes.TITLE
at.loID = nod.parentNode.attributes.ID
at.pID = nod.attributes.ID
} else if (nod.nodeName == "LO ") {
to_xml.appendChild(new XMLNode(1, "LO "));
at = to_xml.lastChild.attributes;
at.label = nod.attributes.TITLE;
at.loID = nod.attributes.ID;
fn(to_xml.lastChild, nod);
}
}
};
///////////////////////////////////////////////////
n_xml = new XML();
n_xml.load( "needed.xml ");
n_xml._parent = this;
n_xml.ignoreWhite = true;
n_xml.onLoad = function(ok) {
if (!ok or this.status) {
return trace( "loaded: "+ok+ " valid: "+!this.staus);
}
trace( "needed: ");
trace(this.tabbedString);
};
--
Ivan Dembicki
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___
iv@(protected) | | http://www.design.ru
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:104918
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |