Would probably make more sense to structure your xml as follows to
collect all stories, then collect info for an individual story

<issue>
        <stories>
                <story>
                        <headline>Headline 1</headline>
        
<detail><p>paragraph</p><p>paragraph</p></detail>
                </story>
                <story>
                        <headline>Headline 1</headline>
        
<detail><p>paragraph</p><p>paragraph</p></detail>
                </story>

.... etc.
        </stories>
</issue>

Then you could then use XPath to parse the xml like this...

// import XPathDocument
import com.xfactorstudio.xml.xpath.XPathDocument
// create arrays for headline & detail 
var headline_array:Array = new Array()
var detail_array:Array = new Array()
// create XPathDocument for issue
var issueXML:XPathDocument = new XPathDocument()
issueXML.ignoreWhite = true
var me = this
issueXML.onLoad = function(success){
        me.parseIssues()
}
issueXML.load("myxml.xml")
// parse XML
function parseIssues()
{
        var inXML:Array
        inXML = issueXML.selectNodes("//story")
        var i,j
        for(i=0;i<inXML.length;i++)
        {       
                j = inXML[i]
                headline_array[i] =
j.selectSingleNode("./headline/text()")
                detail_array[i] =
j.selectSingleNode("./detail").toString()
        }
}

Should be no need for CDATA tags...

HTH



Chris Wilcox
________________________________


 
 
Bounce Digital Ltd  
12 Goslett Yard | London | WC2H 0EQ UK 
T +44(0)207 478 4488 | www.bouncedigital.co.uk

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Miles
Thompson
Sent: 26 October 2005 16:02
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Nothing returned from XML stream ...partway
there

When the XML is generated, if the content of the <head> and <story> tags
is 
bracketed with a <![CDATA[  and ]]> I get the cotent I want through the 
recursive extractContent() method. Xpath.selectNodes still returns
undefined.

MT

At 10:19 AM 10/26/2005, you wrote:
>I'm trying to use the ideas / examples in Steve Nelson's excellent
rssFeed 
>tutorial to modify a Flash movie used to display a daily news digest.
As 
>you can probably guess, I'm not having a lot of success.
>
>Until now, the issue has been returned as an XML file with this format
><issue>
><copy>
>     the contents of the entire issue, with apostrophes, quotes, HTML 
> tags, etc.
></copy>
></issue>
>
>and I was able to feed it to the text display quite simply, with this
line:
>
>         txtNews.text = xmlReceiver.firstChild.firstChild;
>
>where xmlReceiver is
>         var xmlReceiver:XML = new XML();
>called like so
>         xmlReceiver.load( "http://"; + host + "feed_xml_story.php");
>and the assignment to txtNews is made in the xmlReceiver.onLoad = 
>function(success:Boolean) event / success function.
>
>Now we want clickable headlines, so it's no longer a simple procedure
of 
>"grab everything and dump it". I need an array of headlines and a 
>corresponding array of news stories. When the headline is clicked, the 
>news story will be loaded into the adjacent text area.
>
>To avoid two  trips to the database, one to fetch headlines, the other
to 
>get the stories, I decided a more complex XML stream would be  returned
by 
>the script, which has this structure:
>
><issue>
><copy>
>    <head>
>         a headline, including <b> and <br> tags, properly closed
>    </head>
>    <story>
>          the associated story, 200 words or better, with apostrophes, 
> quotes, equal signs, HTML tags, etc., in which the tags are properly
closed.
>    </story>
>    // and there may be 10 ~ 15 head - story combinations
></copy>
></issue>
>
>I've tried both the XPath and the recursive function approaches. They
do 
>not throw any errors, BUT don't return anything.
>
>I tried:
>         trace("XPath.selectNodes:" + XPath.selectNodes(this,
"//head"))
>thinking it would return all of the headlines - but nothing.
>
>And also:
>         trace(extractContent (this, "head")
>with c.nodeType != 3  and also with c.nodeType = 3, thinking it would
do 
>return headlines, but it returns null.
>I can watch extractContent() in the debugger, and it's finding things
like 
><br>.
>
>Other attempts have been made, replacing "this" with "xmlReceiver", 
>"xmlReceiver.firstChild", or "xmlReceiver.firstChild.firstChild".
>
>My dark suspicion is that each regards the HTML tags as new XML fields,
so 
>nothing gets returned. The XML stream was originally decided on because
it 
>could contain everything, returning the story contents to a variable,
as 
>one would with LoadVars, tripped over junk contained in the stories, 
>especially equal signs.
>
>Could this be so? Am I doomed to two trips to the server, one to fetch 
>headlines, the other the stories?
>
>Regards - Miles Thompson
>
>PS I downloaded the latest version of XPath from the X Factor Studio
site. /mt
>
>
>_______________________________________________
>Flashcoders mailing list
>[email protected]
>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
______________________________________________________________________
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to