Ah, fixing it on the Javascript side! That makes a lot more sense. (And
there's no double-load.)

Thanks--I'll give this a try. (It's kind of hard to read, though ... but
I guess that can be good with Javascript....)
―
Mike Keesey

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of Marcelo Volmaro
> Sent: Thursday, November 09, 2006 12:07 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Grabbing data directly from the HTML page
> 
> Use the code below. I did it for my implementation of a flash
replacer,
> and works like a charm.
> 
> input: an html node (node = document.getElementById("nodename"))
> output: a perfectly valid XML reconstruction of the tree below the
node.
> Works on all browsers.
> 
> parseTree = function ($node) {
>       if ($node == null) return '';
>       if ($node.nodeType == null) return '';
> 
>       var $result = '';
> 
>       var $chn = $node.childNodes;
>       if ($chn != null) {
>               var $lchnl = $chn.length;
>               if ($lchnl > 0) {
>                       var $zchild;
>                       var $ynodeNamesWeIgnore =
>
'accessKey|coords|noWrap|dataFormatAs|disabled|dataSrc|object|dataFld|la
ng
>
uage|compact|contentEditable|inherit|tabIndex|align|clear|shape|charset|
ur
> n|rel|rev|dir|css';
> 
>                       for (var $j = 0; $j < $lchnl; $j++) {
>                               $zchild = $chn[$j];
>                               switch ($zchild.nodeType) {
>                                       case 3:
>                                               var $val =
> $zchild.nodeValue.replace(/[\t\n\r\f]*/g, '');
>                                               if ($val.replace(/ */g,
'') != '') {
>                                                       $result +=
> '<![CDATA['+$val+']]>';
>                                               }
>                                       break;
> 
>                                       case 1:
>                                       var $tag_name =
> $zchild.nodeName.toLowerCase();
>                                       $result += '<' + $tag_name;
>                                       var $wnattr =
$zchild.attributes;
> 
>                                       if ($wnattr != null) {
>                                               var $xnal =
$wnattr.length;
> 
>                                               if ($xnal) {
>                                                       for (var $i = 0;
$i < $xnal;
> $i++) {
>                                                               var
$qnodeName =
> $wnattr.item($i).nodeName;
>                                                               if
> (($wnattr.item($i).value != 'null') &&
> ($ynodeNamesWeIgnore.indexOf($qnodeName) == -1)) {
>
$result += ' ' +
> $wnattr.item($i).nodeName.toLowerCase() + '="'
> +$wnattr.item($i).value +'"';
>                                                               }
>                                                       }
>                                               }
>                                       }
> 
>                                       if ($zchild.canHaveChildren ||
> $zchild.hasChildNodes()){
>                                               $result += '>';
>                                               $result +=
parseTree($zchild);
>                                               $result +=
'</'+$tag_name+'>';
> 
>                                       } else {
>                                               $result += ' />';
>                                       }
>                               }
>                       }
>               }
>       }
> 
>       return $result;
> }

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to