I have put together a simple flash that parses some text from a very simple XML, and it works just fine. Here is how the XML looks like
Now I would like the flash to make a difference between 3 different <types> tags in the XML. Then parse it togheter, but depending on witch <type> you choose it becomes slightly different in the layout. This is how the XML looks like
My actionscript that parses the "simple" XML looks like this right now
Dose anyone have any suggestions or tutorials on how to do the things i like to do?
Code:
<result>
<header>text</header>
<content>text text</content>
<info>text text text</info>
<link>http://www.google.com</link>
</result>
Code:
<result>
<type>layout1</type>
<header>text</header>
<content>text text</content>
<info>text text text</info>
<link>http://www.google.com</link>
</result>
<result>
<type>layout2</type>
<header>text</header>
<content>text text</content>
<info>text text text</info>
<price>100</price>
<link>http://www.google.com</link>
</result>
<result>
<type>layout3</type>
<header>text</header>
<content>text text</content>
<info>text text text</info>
<price>100</price>
<units>100</untis>
<link>http://www.google.com</link>
</result>
Code:
function processXMLData(success)
{
if (success)
{
var rootNode=this.firstChild;
var headerNode=findNode(rootNode, "header");
header=getValue(headerNode);
var contentNode=findNode(rootNode, "content");
content=getValue(contentNode);
var infoNode=findNode(rootNode, "info");
info=getValue(infoNode);
var linkNode=findNode(rootNode, "link");
link=getValue(linkNode);
}
else
{
content="Not found";
}
}
function getValue(node)
{
if (node && node.firstChild)
return node.firstChild.nodeValue;
return "";
}
function findNode(node, nodeName)
{
if (node.nodeName==nodeName)
return node;
for (var i=0; node.childNodes && i<node.childNodes.length; i++)
{
var foundNode=findNode(node.childNodes[i], nodeName);
if (foundNode!=null)
return foundNode;
}
return null;
}
link_btn.onRelease = function() {
getURL(link, "_blank");
};
var xmlData=new XML();
xmlData.ignoreWhite=true;
xmlData.onLoad=processXMLData;
xmlData.load("info.xml");
stop();




Linear Mode

