-3

私はいくつかの XML 構造を解析する方法を知っていますが、現在、私が慣れているものとは少し異なるこの特定の xml 構造を解析しようとしています。

しかし今、私はいくつかのxmlを使って作業しています..助けてください。

<?xml version="1.0" encoding="UTF-8"?>
<EssentialPhoneNumbers>
    <Department>
        <Name>Direct sales department</Name>
        <Phone>03-6380000</Phone>
        <Hours>Sunday - Thursday 20:00 to 8:30. Fridays and holiday eves: 8:00 to 12:00</Hours>
        <Contacts>
            <Contact>
                <Name>Inquiries about purchasing life and health insurance</Name>
                <Phone>03-6380390</Phone>
                <Fax>NA</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Inquiries about purchasing car insurance, apartment and office</Name>
                <Phone>03-6380350</Phone>
                <Fax>NA</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Doctors - medical bug reports or claims (MCI Inc.)</Name>
                <Phone>03-6380406</Phone>
                <Fax>03-6380345</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Focus option - all health insurance</Name>
                <Phone>03-6380204</Phone>
                <Fax>03-5244401</Fax>
                <Hours>Sunday - Thursday 20:00 to 8:30</Hours>
            </Contact>
            <Contact>
                <Name>General insurance claims department Avinoam Ike</Name>
                <Phone>03-6380429</Phone>
                <Fax>NA</Fax>
                <Hours>NA</Hours>
            </Contact>
        </Contacts>
    </Department>
    <Department>
        <Name>Service Department</Name>
        <Phone>03-6380350</Phone>
        <Hours>Sunday - Thursday 6:00 p.m. to 8:00 a.m. Fridays and holiday eves: 8:00 to 12:00</Hours>
        <Contacts>
            <Contact>
                <Name>Center and emergency assistance services 24 hours a day</Name>
                <Phone>1-800-280-555</Phone>
                <Fax>NA</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Advice on medico - wavy insured professional liability insurance - medical(MCI Inc. )</Name>
                <Phone>03-6380346</Phone>
                <Fax>03-6380345</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Urgent questions on Medico - Records (other than the hours at the office )</Name>
                <Phone>052-227633</Phone>
                <Fax>NA</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Inquiries about professional liability insurance - medical</Name>
                <Phone>03-6380480</Phone>
                <Fax>03-6380461</Fax>
                <Hours>NA</Hours>
            </Contact>
            <Contact>
                <Name>Team members focus</Name>
                <Phone>1-700-700-251</Phone>
                <Fax>NA</Fax>
                <Hours>Sunday - Thursday 20:00 to 8:00</Hours>
            </Contact>
            <Contact>
                <Name>Inquiries about Medical Risk Management(MRM)</Name>
                <Phone>03-6380458</Phone>
                <Fax>03-6380345</Fax>
                <Hours>NA</Hours>
            </Contact>
        </Contacts>
    </Department>
</EssentialPhoneNumbers>
4

2 に答える 2

0

TBXMLParser を使用しています。

これが私のコードです

 dataForParser = [queryResult dataUsingEncoding:NSUTF8StringEncoding];  
    TBXML *tbxml = [TBXML tbxmlWithXMLData: dataForParser];
    TBXMLElement *root = tbxml.rootXMLElement;
    if (root) {
        TBXMLElement *item = [TBXML childElementNamed:@"item" parentElement:root];
            while (item) {
                NSString * type = [NSString stringWithFormat:[TBXML valueOfAttributeNamed:@"type" forElement:item]];
                if ([type isEqualToString:@"0"]) { 

                    Chair *ch = [[Chair alloc] init];

                    NSMutableArray * chairsAr = [[NSMutableArray alloc] init];
                    [chairsAr addObject: type];

                    ch.chairPic = [NSString stringWithFormat:[TBXML valueOfAttributeNamed:@"picture" forElement:item]];
                    ch.xChObject = [NSString stringWithFormat:[TBXML valueOfAttributeNamed:@"x" forElement:item]];
                    ch.yChObject = [NSString stringWithFormat:[TBXML valueOfAttributeNamed:@"y" forElement:item]];
                    ch.chairAngle = [NSString stringWithFormat:[TBXML valueOfAttributeNamed:@"angle" forElement:item]];

                    [allChairs addObject:ch];
于 2013-06-13T05:57:35.493 に答える