2

我有一些xml,我有属性值,我需要比较表id来获取属性值。迪斯是我的

xml

 <response>

         <baccarat>

             <Game Gametype="Euro Baccarat 1" tableid="bc7ire5oi4uhetfd" studio="Manila-VIP">

                 <table type="low" min="1" max="100" >
                <betType type="side" min="1" max="100" />
                     <betType type="tie" min="10" max="30" />
                    <betType type="pair" min="10" max="22" />
                     <betType type="chip" chip="1,5,10,25,50,75,100" />
                     <betType type="default" chip="0" />
                 </table>

                 <table type="regular" min="10" max="250" >
                     <betType type="side" min="10" max="250" />
                     <betType type="tie" min="10" max="30" />
                     <betType type="pair" min="10" max="22" />
                     <betType type="chip" chip="1,5,10,25,50,100,250" />
                     <betType type="default" chip="2" />
                 </table>
                 <table type="high" min="50" max="500" >
                     <betType type="side" min="50" max="500" />
                     <betType type="tie" min="50" max="120" />
                     <betType type="pair" min="50" max="90" />
                     <betType type="chip" chip="1,5,10,25,50,100,500" />
                     <betType type="default" chip="4" />
                 </table>
                 <table type="vip" min="5" max="300" >
                     <betType type="side" min="5" max="300" />
                     <betType type="tie" min="5" max="100" />
                     <betType type="pair" min="5" max="75" />
                     <betType type="chip" chip="1,5,10,25,50,100,300" />
                     <betType type="default" chip="1" />
                 </table>
                 <table type="agent1" min="100" max="1000" >
                     <betType type="side" min="100" max="1000" />
                     <betType type="tie" min="100" max="600" />
                     <betType type="pair" min="100" max="450" />
                     <betType type="chip" chip="10,50,100,500" />
                     <betType type="default" chip="1" />
                 </table>
                 <table type="agent2" min="500" max="5000" >
                     <betType type="side" min="500" max="5000" />
                     <betType type="tie" min="500" max="1200" />
                     <betType type="pair" min="500" max="900" />
                     <betType type="chip" chip="10,50,100,500" />
                     <betType type="default" chip="1" />
                 </table>
                 <table type="private" min="5" max="300" >
                     <betType type="side" min="5" max="300" />
                     <betType type="tie" min="5" max="100" />
                     <betType type="pair" min="5" max="75" />
                     <betType type="chip" chip="1,5,10,25,50,100,300" />
                     <betType type="default" chip="1" />
                 </table>
             </Game>

<table type="low" min="1" max="100" >
    <betType type="side" min="1" max="100" />
    <betType type="tie" min="10" max="30" />
    <betType type="pair" min="10" max="22" />
    <betType type="chip" chip="1,5,10,25,50,75,100" />
    <betType type="default" chip="0" />
</table>

    <table type="regular" min="10" max="250" >
    <betType type="side" min="10" max="250" />
    <betType type="tie" min="10" max="30" />
    <betType type="pair" min="10" max="22" />
    <betType type="chip" chip="1,5,10,25,50,100,250" />
    <betType type="default" chip="2" />
</table>

    <table type="high" min="50" max="500" >
    <betType type="side" min="50" max="500" />
    <betType type="tie" min="50" max="120" />
    <betType type="pair" min="50" max="90" />
    <betType type="chip" chip="1,5,10,25,50,100,500" />
    <betType type="default" chip="4" />
</table>
    <table type="vip" min="5" max="300" >
    <betType type="side" min="5" max="300" />
    <betType type="tie" min="5" max="100" />
    <betType type="pair" min="5" max="75" />
    <betType type="chip" chip="1,5,10,25,50,100,300" />
    <betType type="default" chip="1" />
</table>
    <table type="agent1" min="100" max="1000" >
    <betType type="side" min="100" max="1000" />
    <betType type="tie" min="100" max="600" />
    <betType type="pair" min="100" max="450" />
    <betType type="chip" chip="10,50,100,500" />
    <betType type="default" chip="1" />
</table>
    <table type="agent2" min="500" max="5000" >
    <betType type="side" min="500" max="5000" />
    <betType type="tie" min="500" max="1200" />
    <betType type="pair" min="500" max="900" />
    <betType type="chip" chip="10,50,100,500" />
    <betType type="default" chip="1" />
</table>
<table type="private" min="5" max="300" >
    <betType type="side" min="5" max="300" />
    <betType type="tie" min="5" max="100" />
    <betType type="pair" min="5" max="75" />
    <betType type="chip" chip="1,5,10,25,50,100,300" />
    <betType type="default" chip="1" />
</table>

Dis my xml in dis xml 我需要检查表 id 如果表 id 属性等于 dis bc8kuw8luk1dgfhy 我需要进入并获取所有属性的值示例类型低我需要获取最小最大值的属性,就像我一样需要获取所有属性值。现在我正在使用日志获取所有值来显示我需要存储它并获取我想要使用的值。在解析器中删除我的日志

 NSLog(@"elementName %@",elementName);
NSLog(@"attributeDict %@",attributeDict);
4

1 回答 1

0

试试这个

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName 属性:(NSDictionary *)attributeDict
{
    currentelement=[elementName mutableCopy];
    if([elementName isEqualToString:@"Game"]&&[[attributeDict objectForKey:@"tableid"] isEqualToString:@"bc8kuw8luk1dgfhy"])
    {
        isTableIdMatching = 是;
    }
    else if(isTableIdMatching && [elementName isEqualToString:@"table"]&&[[attributeDict objectForKey:@"type"] isEqualToString:@"low"]){
        低字典 = 属性字典;
    }
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{

}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURIqualifiedName:(NSString *)qName
{
    if ([elementName isEqualToString:@"table"]&& lowDict) {
        NSLog(@"low类型的属性值是---%@",lowDict);
        lowDict = 无;
    }else if([elementName isEqualToString:@"Game"]){
        isTableIdMatching = 否;
    }
}
于 2013-09-12T07:07:35.640 回答