开发者

NSXMLParser with multiple delegates

I'm trying to parse an xml tree file whith multiple NSXMLParserDelegate parsers but I'm getting in the next issue.

My XML structure is something like that.

<Object1>
     <Name>Ricky</Name>
     <Surname>Woodstock</Surname>
     <Adress>
          <City>Los Angeles</City>
          <State>California</State>
          <Country>USA</Country>
     </Adress>
     <Items>
          <Item>
               <Id>1</Id>
               <Description>Sports Bag</Description>
               <Price>13.45</Price>
          </Item>
          <Item>
               <Id>2</Id>
               <Description>Baseball Cap</Description>
               <Price>6.90</Price>
          </Item>
     </Items>
     <Total>20.15</Total>
</Object1>

And my Issue is that when I changes delegates, it starts parsing not in top-level tag, instead it begins parsing on the first nested tag.

For example.

  1. I begin parsing XML wih XMLObject parser which parses element

  2. When it reaches Adresss tag I set delegate to XMLAdressParser (and set XMLAdressParser's parent to self for returning) but XMLAdressParser begins parsing on tag.

  3. And almost with Items and Item tags.

I think it's normal cause of a Parser definition, but that's the question:

Is there any way for the delegate to start parsing in correspondint tag, like first one?

Thanks in ad开发者_运维知识库vance for any help.

Sergio


Rather than using multiple delegates I suggest using a single delegate and having it distribute the work as you feel appropriate.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜