开发者

SMIL file xml isn't e4x friendly?

开发者 https://www.devze.com 2023-03-04 17:39 出处:网络
I\'m loading in a smil file (follows the xml format) and it won\'t let me select properties via name (eg. xml.body) instead I can only access the data by xml.child(0).

I'm loading in a smil file (follows the xml format) and it won't let me select properties via name (eg. xml.body) instead I can only access the data by xml.child(0).

I've tried xml.child('body'), but still nothing. Anyone know a quick workaround? I would like to be able to access xml.head.(@name=='rtmpPlaybackbase') and the XMLList xml.body.switch.video

<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head>
   <meta name="title开发者_如何学编程" content="myStream"/>
   <meta name="httpBase" content="http://mydomain.com/"/>
   <meta name="rtmpPlaybackBase" content="http://mydomain.com/"/>
</head>
<body>
   <switch>
      <video src="myStream500K@54552" system-bitrate="500000"/>
      <video src="myStream900K@54552" system-bitrate="900000"/>
      <video src="myStream1500K@54552" system-bitrate="1500000"/>
   </switch>
</body>

Many Thanks!


First of all, close your start tag , in the end with . Let's say you have it now like this:

var xml:XML = new XML('<smil xmlns="http://www.w3.org/2001/SMIL20/Language"><head><meta name="title" content="myStream"/><meta name="httpBase" content="http://mydomain.com/"/><meta name="rtmpPlaybackBase" content="http://mydomain.com/"/></head><body><switch><video src="myStream500K@54552" system-bitrate="500000"/><video src="myStream900K@54552" system-bitrate="900000"/><video src="myStream1500K@54552" system-bitrate="1500000"/></switch></body></smil>');

Then if you trace the length of xml.body, it gives 0.

trace(String(xml.body).length); //traces 0

This is mainly because you have to use xml namespace:

var ns:Namespace = new Namespace("http://www.w3.org/2001/SMIL20/Language");

Now use this namespace to reach your tags in the xml:

trace(String(xml.ns::body).length); //traces 272

So xml.ns::TAGNAME is how you reach it.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消