1

私はXMLにまったく慣れていません。

Microsoft .asxファイルを解析して iPhone で mms ストリームを順番に再生するカスタム クラスを作成するのに役立つサンプル コードはありますか?

いくつかのグーグルは、.xml と .asx が多少関連していることを明らかにしましたが、最初のものと比較すると、2 番目のものは非常に限られています。

次のように、 .asxコンテナー内で 3 つのストリームを順番に再生する必要があります。

<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コンテンツを解析して、ストリームを順番に再生することはまだできません。ありがとう!

4

1 に答える 1

0

私の場合、このコードを使用してTouchXMLを使用して .asx ファイルを正常に解析できました (次の場所で入手可能な元のバージョンから変更しましたhttp://foobarpig.com/iphone/parsing-xml-element-attributes-with-touchxml.html):

         //  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); 
于 2011-11-10T15:59:34.317 に答える