Skip to main content
Known Participant
February 19, 2010
Question

XML how to target child

  • February 19, 2010
  • 2 replies
  • 498 views

<?xml version="1.0" encoding="UTF-8"?> <tt xml:lang="en" xmlns="http://www.w3.org/2006/04/ttaf1"  xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling">      <head>           <styling>                <!-- Add styles here -->           </styling>      </head>            <body>           <div xml:lang="en">                <p begin="00:00:00.00">Caption 1</p>                <p begin="00:00:15.00">Caption 1</p>           </div>           <div xml:lang="de">                <p begin="00:00:00.00">Caption 1</p>                <p begin="00:00:15.00">Caption 1</p>           </div>      </body> </tt>

I think this is a simple question, but can't quite figure it out. How would i read the <div> that is english "en"?

something like this - tho this does not work:

trace(_xml.div.(@lang=="en"));

This topic has been closed for replies.

2 replies

3BEANAuthor
Known Participant
February 19, 2010

Yeah, I have a feeling the <div xml:lang="en"> tag is the problem.

I am trying to use that format as it is a "standards" thing for captioning "Timed Text (TT) XML document". (i know there is a closed captions component, but it's results have been less than stellar)

I am probably going to have to abandon that standard markup for the sakes of getting this done, but I am sure there is a way. I think it has something to do with name spaces and such that have been introduced to xml in as3.

February 19, 2010

Actually, I'm pretty sure you can use it, but you'll need to look into the QName and Namespace classes. For example, remove the first line of your xml, the xml definition line, so that you start with the <tt tag. Then trace your _xml variable. You will see your <div xml:lang tags change to <div aaa:lang tags - and that a new namespace is added into your tt tag: aaa. So you need to use the namespace to get the data...

February 19, 2010

<div xml:lang="en">

I don't think the xml: is going to fly. It should be just:

<div lang="en">

And then to get that xml you need to include the body tag like:

trace(_xml.body.div.(@lang=="en"));