Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

<< Prev 5 | Next 5

get TextNode From XML tag

function getTextNodeFromXMLtag (myXML, tag) {
        var AY;
        Nodes=new Array();
        AY=myXML.toString().split("<"+tag);
        AY.shift();
        for (var i=0; i<AY.length; i++) {
                if (AY[i].charAt(0)==">" or AY[i].charAt(0)==" ") {
                        Nodes.push(AY[i].substring((AY[i].indexOf(">")+1), AY[i].indexOf("</"+tag+">")));
                }
        }
        return Nodes;
}

Posted by: Daniel Kiss | website http://www.deltabroker.at
Get the value of attribute from a specified tags
function getAttrValueFromXMLtag (myXML, tag, attr) {
        var subXML, attrValue;
        Values=new Array();
        subXML=myXML.toString().split("<"+tag);
        subXML.shift();
        for (var i=0; i<subXML.length; i++) {
                // for both <empty attr="value">/> and <non attr="value">empty</non> xml elements
                if (subXML[i].indexOf("</"+tag+">")>=0) {
                        subXML[i]="<"+tag+subXML[i].substring(0, subXML[i].indexOf("</"+tag+">"))+"</"+tag+">";
                } else if (subXML[i].indexOf("/>")>=0) {
                        subXML[i]="<"+tag+subXML[i].substring(0, subXML[i].indexOf("/>"))+"/>";
                } else { subXML[i]="hiba;"}
                childXML=new XML(subXML[i]);
                attrValue=eval("childXML.firstChild.attributes."+attr);
                if (attrValue.length>0) {Values.push(attrValue);}
        }
        return Values;
}

Posted by: Daniel Kiss | website http://www.deltabroker.at
getElementListByName
XMLnode.prototype.getElementListByName = function (str)
// PARAMS:
//   STR is a string that is to be matched against element
//   names within the node (XMLNode) and its children (XMLNode).
// RETURN:
//   An array of XMLNode objects where the node names match STR.
// AUTHOR:
//   Mike Brittain, EmbiMEDIA
//   http://www.embimedia.com/
{
        var nodeArr = new Array();
        var searchNode;
        
        if ( !this.hasChildNodes() ) {
                // No children to search.
                return nodeArr;
        }
        
        // Descend and search children.
        searchNode = this.firstChild;
        while (searchNode != null) {
                if (searchNode.nodeType == 1 && searchNode.nodeName == str) {
                        // Match!
                        nodeArr.push( searchNode );
                }
                if (searchNode.nodeType == 1 && searchNode.hasChildNodes()) {
                        // Recursively search the child nodes.
                        nodeArr = nodeArr.concat( searchNode.getElementListByName(str) );
                }
                // Advance to next node.
                searchNode = searchNode.nextSibling;
        }
        
        // Return the array to original call, or to the
        // last recursive call.
        return nodeArr;
};

Posted by: Mike Brittain | website http://www.embimedia.com/
getElementsTagByName
// special DOM interface "getElementsTagByName" method
// targetName [string]
// returnValue [array / null] : node list
//
// var elements = MyXML.getElementsByTagName("targetName");
// for (var i = 0; i < elements.length; i++) {
//   var item = elements[i].firstChild.nodeValue;
// }

XML.prototype.getElementsByTagName = function (targetName) {
        // index of return value
        var index = 0;
        // return value
        var returnValue = new Array();
        
        diverDown(this,targetName);
        
        if (returnValue.length == 0) returnValue = null;
        
        return returnValue;
        
        // local function
        function diverDown(node,targetName) {
                var nodeList = node.childNodes;
                for (var i = 0; i < nodeList.length; i++) {
                        if (nodeList[i].nodeType == 1 && nodeList[i].hasChildNodes) {
                                if (nodeList[i].nodeName == targetName) {
                                        for (var n = 0; n < nodeList[i].parentNode.childNodes.length; n++) {
                                                if (nodeList[i].parentNode.childNodes[n].nodeName == targetName) {
                                                        returnValue[index] = nodeList[i].parentNode.childNodes[n];
                                                        index++;
                                                }
                                        }
                                        return;
                                } else {
                                        diverDown(nodeList[i], targetName);
                                }
                        }
                }
                index = 0;
        }
}

Posted by: KANNY nobuyoshskii | website http://ktd.jp/
load data and images through xml
//The name of xml file is "book.xml"

//first frame

myxml = new XML();
myxml.ignoreWhite = true;
myxml.load("book.xml");
function process1(pic, name) {
        pic = myxml.firstChild.childNodes[0].attributes.pic;
        name=myxml.firstChild.childNodes[0].childNodes[0];
        loadMovie(pic, "sam");
        text=name;
}
function process2(pic, name) {
        pic = myxml.firstChild.childNodes[1].attributes.pic;
        name=myxml.firstChild.childNodes[1].childNodes[0];
        loadMovie(pic, "sam");
        text=name;
}

//movieclp


onClipEvent(enterFrame){
        if(this._url != _root._url && !loaded) {
                var kilobytes = Math.ceil(this.getBytesTotal()/1024);
                var percentLoaded = Math.ceil((this.getBytesLoaded()/this.getBytesTotal()) * 100);
                _root.counter = "loading " + percentLoaded + "% of " + kilobytes + "k";
                _root.loading="Movie is loading, please wait.";
                if(percentLoaded == 100){
                        loaded = true;
                        _root.counter = "Ready";
                        _root.loading="";
                }
        }
}



//button

on (release) {
        process1();
}


//button

on (release) {
        process2();
}


//For create xml file U have to simple copy text which is given below paste into notepad file and save as book.xml

<?xml version"1.0"?>
<Models>
<Riya name="Riya" pic="images/pic_1.swf">Age:22
height:5fit
weight:60kg
</Riya>
<Divya name="Divya" pic="images/pic_2.swf">Age:24
height:6fit
weight:67kg
</Divya>
</Models>

Posted by: Gurmeet Singh | website http://www.oasesindia.net/sunny

<< Prev 5 | Next 5

Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.