A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Xml

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    3

    Angry XML file contains <table> tags!!!!

    Here's the XML file

    Code:
    <rss version="2.0" xmlns:nasdaq="http://nasdaq.com"><channel><title>NASDAQ.com Stock Tracker</title><link>http://www.nasdaq.com</link><description>Track your favorite stock and link to NASDAQ.com for the full details.</description><copyright>Copyright 2005 - 2010 NASDAQ.com. All rights reserved.</copyright><item><pubDate>7 Apr 2009 16:00:00 EDT</pubDate><title>7 Apr 2009 16:00:00 EDT - The latest stock information is now available for your stocks</title><author>feedback@nasdaq.com</author><description><![CDATA[	
    
            ><table border=0 cellspacing=0 cellpadding=0 width="200"> 
                <TR bgcolor="#DDDDDD"> 
    						<TD ALIGN="LEFT" COLSPAN=2 nowrap><a href="http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=MSFT&selected=MSFT">MSFT</a> &nbsp; 
    						</TD> 
    			</TR> 
                <TR bgcolor="#EEEEEE"> 
    						<TD nowrap width="50%">&nbsp;Last 
    						</TD> 
    						<TD nowrap align=right width="50%">18.76
    						</TD> 
    			</TR> 
                <TR bgcolor="#DDDDDD"> 
    						<TD nowrap width="50%">&nbsp;Change 
    						</TD> 
    		                <TD nowrap align=right width="50%"><font color="black">unch</font>&nbsp;
    						</TD> 
    			</TR> 
                <TR bgcolor="#EEEEEE"> 
    						<TD nowrap width="50%">&nbsp;% Change 
    						</TD> 
    		                <TD nowrap align=right width="50%"><font color="black">unch</font>&nbsp;
    						</TD> 
    			</TR> 
                <TR bgcolor="#DDDDDD"> 
    						<TD nowrap width="50%">&nbsp;Volume 
    						</TD> 
    		                <TD nowrap align=right width="50%">65,793,013&nbsp;
    						</TD> 
    			</TR> 
    				</TABLE> 
     
    				<TABLE WIDTH=180>			
    		            <TR bgcolor="#EEEEEE"> 
    						<TD nowrap>&nbsp;As of: 7 Apr 2009 16:00:00 EDT&nbsp;
    						</TD> 
    					</TR> 
     
    					<TR bgcolor="#DDDDDD"> 
    						<TD COLSPAN=2 nowrap>&nbsp;View: <a title="MSFT Stock Quote" href="http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=MSFT&selected=MSFT">Stock Quote</a> | &nbsp;<a title="MSFT News" href="http://www.nasdaq.com/aspxcontent/newsheadlines.aspx?symbol=MSFT&selected=MSFT">News</a><BR> 
    						</TD> 
    					</TR> 
    					<TR> 
    						<TD COLSPAN=2 nowrap>&nbsp;
    						</TD> 
    					</TR> 
    				</TABLE> 
    
    ]]></description><link>http://www.nasdaq.com/quote.dll?rss=StockQuotes&amp;mode=stock&amp;page=multi&amp;symbol=MSFT</link><guid>http://www.nasdaq.com/quote.dll?rss=StockQuotes&amp;mode=stock&amp;page=multi&amp;symbol=MSFT</guid></item></channel></rss>
    Now here's the Question.... how do i get to the data between the CDATA and the Tables, TR, TD tags?

    is it even possible?

    AS3 Code Below:
    Code:
    var xmlLoader:URLLoader = new URLLoader()
    xmlLoader.addEventListener(Event.COMPLETE, showXML)
    xmlLoader.load(new URLRequest("http://www.nasdaq.com/aspxcontent/NasdaqRSS.aspx?data=quotes&symbol=MSFT"))
    function showXML(e:Event):void {
    var y:XML = new XML(e.target.data)
    myTextField.text = y.?????????????????????????;
    }
    Any help with this would be great
    c0der
    Last edited by c0der; 04-08-2009 at 10:55 AM.

  2. #2
    I Love India Nalini_v's Avatar
    Join Date
    Jun 2007
    Location
    Chennai
    Posts
    195
    Hi,

    You can't

    because the <table> tags inside the <!CDATA is not in proper case.. The whole data inside the <!CDATA can be get by

    function showXML (e:Event):void {
    var yXML:XML = new XML(e.target.data);
    yXML.ignoreWhitespace = true
    var newXMLNode:XML = new XML(yXML.channel[0].item[0].description);
    trace (newXMLNode);
    }

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    3
    So, what we are saying here is that...

    if the XML file contains <table> tags etc, i cannot feed the data i want into my Flash movie?

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    myText.text=xml.channel.item.description;
    or
    myText.text=xml.child(0).child(4).description;
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Junior Member
    Join Date
    Apr 2009
    Posts
    3
    myText.text=xml.channel.item.description;
    OK, this is the output i'm getting from this....

    Code:
    	
    <table border=0 cellspacing=0 cellpadding=0 width="200">
    <TR bgcolor="#DDDDDD">
    <TD ALIGN="LEFT" COLSPAN=2 nowrap><a href="http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=MSFT&selected=MSFT">MSFT</a> &nbsp; 
    </TD></TR>
    <TR bgcolor="#EEEEEE">
    <TD nowrap width="50%">&nbsp;Last</TD>
    <TD nowrap align=right width="50%">19.1</TD>
    </TR>
    <TR bgcolor="#DDDDDD">
    <TD nowrap width="50%">&nbsp;Change 
    </TD>
    <TD nowrap align=right width="50%"><font color="green">+<img src=http://www.nasdaq.com/images/greenarrowsmall.gif >0.34</font>&nbsp;</TD></TR>
    <TR bgcolor="#EEEEEE">
    <TD nowrap width="50%">&nbsp;% Change</TD>
    <TD nowrap align=right width="50%"><font color="green">1.81%</font>&nbsp;
    </TD></TR>
    <TR bgcolor="#DDDDDD">
    <TD nowrap width="50%">&nbsp;Volume</TD>
    <TD nowrap align=right width="50%">9,003,108&nbsp;
    </TD></TR>
    </TABLE>
    <TABLE WIDTH=180>			
    <TR bgcolor="#EEEEEE">
    <TD nowrap>&nbsp;As of: 8 Apr 2009 10:27:26 EDT&nbsp;
    </TD></TR>
    <TR bgcolor="#DDDDDD">
    <TD COLSPAN=2 nowrap>&nbsp;View: <a title="MSFT Stock Quote" href="http://quotes.nasdaq.com/asp/SummaryQuote.asp?symbol=MSFT&selected=MSFT">Stock Quote</a> | &nbsp;<a title="MSFT News" href="http://www.nasdaq.com/aspxcontent/newsheadlines.aspx?symbol=MSFT&selected=MSFT">News</a><BR>
    </TD></TR>
    <TR>
    <TD COLSPAN=2 nowrap>&nbsp;
    </TD></TR></TABLE>
    However i want only the data which is in bold

    i want in my Flash movie a real-time feed from nasdaq.com showing me example....

    STOCK SYMBOL: MSFT
    CURRENT SHARE PRICE: 19.1
    CHANGE: 1.81%

    ... sorry about the confusion

    c0der

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I don't think you are lucky there, since the only way to proceed is converting the CDATA contents to a String first and then back to XML

    var newXML:String=String(xml.channel.item.description) ;
    var tableXML:XML=new XML(newXML);
    myText.text=newXML;

    However, the parser reports that the XML is malformed and that kills it unless you want to continue working with a String. This feed is not made for Flash.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center