soggybag
03-17-2008, 10:20 PM
I'm trying to get the p tags out of this XML document. But I can't seem to figure out what I'm doing wrong. Help me out what am I missing?
I don't get an errors. But i don't see any output? It seems that it is just not finding the p tags.
Here is a snippet of my AS3 code:
private function xml_loaded( e:Event ):void {
var my_xml:XML;
my_xml = new XML( e.target.data );
my_xml.ignoreWhitespace = true;
var style_nodes // :XMLList;
var caption_nodes // :XMLList;
style_nodes = my_xml.child( "styling" );
caption_nodes = my_xml.tts.body.child( "p" );
// caption_nodes = my_xml.child( "p" );
for each ( var p in caption_nodes ) {
var _obj:Object = new Object();
var cap_text:String = p.toString();
var begin:String = p.attribute( "begin" ).toString();
var end:String = p.attribute( "end" ).toString();
trace( begin + ":" + ":" + end + " " + cap_text );
_obj.cap_text = cap_text;
}
Here's a snippet of the XML. There are no errors here I have used this file with different cod and works fine.
<?xml version="1.0" encoding="iso-8859-1"?>
<tt xmlns="http://www.w3.org/2006/04/ttaf1" xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling" xml:lang="en">
<head>
<styling>
<style id="defaultSpeaker" tts:fontSize="12px" tts:fontFamily="SansSerif" tts:fontWeight="normal" tts:fontStyle="normal" tts:textDecoration="none" tts:color="white" tts:backgroundColor="black" tts:textAlign="left" />
<style id="defaultCaption" tts:fontSize="12px" tts:fontFamily="SansSerif" tts:fontWeight="normal" tts:fontStyle="normal" tts:textDecoration="none" tts:color="white" tts:backgroundColor="black" tts:textAlign="center" />
</styling>
</head>
<body id="thebody" style="defaultCaption">
<div xml:lang="en">
<p begin="0:00:00.00" end="0:00:01.02"></p>
<p begin="0:00:01.02" end="0:00:02.06">So in 2003,</p>
<p begin="0:00:02.06" end="0:00:05.00">I got married to my husband, who's from Belgium.</p>
<p begin="0:00:07.04" end="0:00:10.06">And we bought a house in Ghent, Belgium.</p>
<p begin="0:00:10.06" end="0:00:12.00">And one summer,</p>
I don't get an errors. But i don't see any output? It seems that it is just not finding the p tags.
Here is a snippet of my AS3 code:
private function xml_loaded( e:Event ):void {
var my_xml:XML;
my_xml = new XML( e.target.data );
my_xml.ignoreWhitespace = true;
var style_nodes // :XMLList;
var caption_nodes // :XMLList;
style_nodes = my_xml.child( "styling" );
caption_nodes = my_xml.tts.body.child( "p" );
// caption_nodes = my_xml.child( "p" );
for each ( var p in caption_nodes ) {
var _obj:Object = new Object();
var cap_text:String = p.toString();
var begin:String = p.attribute( "begin" ).toString();
var end:String = p.attribute( "end" ).toString();
trace( begin + ":" + ":" + end + " " + cap_text );
_obj.cap_text = cap_text;
}
Here's a snippet of the XML. There are no errors here I have used this file with different cod and works fine.
<?xml version="1.0" encoding="iso-8859-1"?>
<tt xmlns="http://www.w3.org/2006/04/ttaf1" xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling" xml:lang="en">
<head>
<styling>
<style id="defaultSpeaker" tts:fontSize="12px" tts:fontFamily="SansSerif" tts:fontWeight="normal" tts:fontStyle="normal" tts:textDecoration="none" tts:color="white" tts:backgroundColor="black" tts:textAlign="left" />
<style id="defaultCaption" tts:fontSize="12px" tts:fontFamily="SansSerif" tts:fontWeight="normal" tts:fontStyle="normal" tts:textDecoration="none" tts:color="white" tts:backgroundColor="black" tts:textAlign="center" />
</styling>
</head>
<body id="thebody" style="defaultCaption">
<div xml:lang="en">
<p begin="0:00:00.00" end="0:00:01.02"></p>
<p begin="0:00:01.02" end="0:00:02.06">So in 2003,</p>
<p begin="0:00:02.06" end="0:00:05.00">I got married to my husband, who's from Belgium.</p>
<p begin="0:00:07.04" end="0:00:10.06">And we bought a house in Ghent, Belgium.</p>
<p begin="0:00:10.06" end="0:00:12.00">And one summer,</p>