首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于iPhone NSXMLParse的.asx文件

用于iPhone NSXMLParse的.asx文件
EN

Stack Overflow用户
提问于 2011-05-16 19:40:39
回答 1查看 550关注 0票数 1

我对XML完全陌生。

是否有人有一个示例代码来帮助我构建一个自定义类,该类将解析微软.asx文件以在iPhone上按顺序播放mms流?

一些谷歌用户向我透露,.xml和.asx有一定的关系,不过第二条相对于前者来说非常有限。

我需要在.asx容器中按顺序播放三个流,如下所示:

代码语言:javascript
复制
<asx version="3.0">
<TITLE>MYSONGS</TITLE>
<entry>
<TITLE>www.mysite.com</TITLE>
<ref href="mms://mysite.com/musicFolder/song1.wma" />
</entry>
<entry>
<TITLE>MYSONGS</TITLE>
<ref href="mms://mysite.com/musicFolder/song2.wma" />
</entry>
<entry>
<TITLE>www.mysite.com</TITLE>
<ref href="mms://mysite.com/musicFolder/song3.wma" />
</entry>
</asx>

我已经能够解析mms流,解码和播放wma文件。我只是还无法解析.asx内容,无法按顺序播放流。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2011-11-10 15:59:34

在我的例子中,我已经能够使用TouchXML成功地解析TouchXML文件(我从http://foobarpig.com/iphone/parsing-xml-element-attributes-with-touchxml.html):的原始版本中修改了这段代码)

代码语言:javascript
复制
         //  we will put parsed data in an a array
        NSMutableArray *res = [[NSMutableArray alloc] init];
        NSURL *url = [NSURL URLWithString: @"http://www.yoursite.com/WindowsMediaDotCom/theFileToParse.asx"];

        /* have TouchXML parse it into a CXMLDocument */
        CXMLDocument *document = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];

        NSArray *nodes = NULL;
        //  searching for piglet nodes
        nodes = [document nodesForXPath:@"//ref" error:nil];

        for (CXMLElement *node in nodes) {
            NSMutableDictionary *item = [[NSMutableDictionary alloc] init];
            int counter;
            for(counter = 0; counter < [node childCount]; counter++) {
                //  common procedure: dictionary with keys/values from XML node
                [item setObject:[[node childAtIndex:counter] stringValue] forKey:[[node childAtIndex:counter] name]];
            }

            //  and here it is - attributeForName! Simple as that.
            [item setObject:[[node attributeForName:@"href"] stringValue] forKey:@"href"];  // <------ this magical arrow is pointing to the area of interest

            [res addObject:item];
            [item release];
        }

        //   and we print our results
        NSLog(@"%@", res); 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6022454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档