RE: [Flashcoders] Nothing returned from XML stream ...partway there

2005-10-26 Thread Chris Wilcox
Would probably make more sense to structure your xml as follows to
collect all stories, then collect info for an individual story




Headline 1

paragraphparagraph


Headline 1

paragraphparagraph


 etc.



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;imailto:[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  and  tags
is 
bracketed with a  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
>
>
> the contents of the entire issue, with apostrophes, quotes, HTML 
> tags, etc.
>
>
>
>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:
>
>
>
>
> a headline, including  and  tags, properly closed
>
>
>  the associated story, 200 words or better, with apostrophes, 
> quotes, equal signs, HTML tags, etc., in which the tags are properly
closed.
>
>// and there may be 10 ~ 15 head - story combinations
>
>
>
>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 
>.
>
>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
>Flashcoders@chattyfig.figleaf.com
>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyf

Re: [Flashcoders] Nothing returned from XML stream ...partway there

2005-10-26 Thread Miles Thompson
When the XML is generated, if the content of the  and  tags is 
bracketed with a  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


the contents of the entire issue, with apostrophes, quotes, HTML 
tags, etc.




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:




   
a headline, including  and  tags, properly closed
   
   
 the associated story, 200 words or better, with apostrophes, 
quotes, equal signs, HTML tags, etc., in which the tags are properly closed.

   
   // and there may be 10 ~ 15 head - story combinations



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 
.


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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders