iPhone xml 反序列化器
我是编程新手,这是我的第一个项目,所以我对 xml 解析等不太了解。 我需要解析一个 xml 文档,就像......
<TLMS><TLMSResponse status="SUCCESS">
<books>
<book>
<name>abc</name>
<author>DEF</author>
<publisher>HIJ</publisher>
</book>
<book>
<name>xyz</name>
<author>rus</author>
<publisher>tuv</publisher>
</book>
</books>
</TLMSResponse></TLMS>
我已经尝试了很多,但还没有找到任何好的反序列化器可以解析这个 xml 并创建“Book”类的对象。 非常感谢任何帮助...
谢谢大家
I am new to programming and this is my first project so I don't have much idea about xml parsing etc.
I need to parse an xml document like...
<TLMS><TLMSResponse status="SUCCESS">
<books>
<book>
<name>abc</name>
<author>DEF</author>
<publisher>HIJ</publisher>
</book>
<book>
<name>xyz</name>
<author>rus</author>
<publisher>tuv</publisher>
</book>
</books>
</TLMSResponse></TLMS>
I have tried a lot but haven't found any good de-serializer that can parse this xml and make objects of "Book" class.
Any help is greatly appreciated...
Thank You all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个实现
NSXMLParserDelegate 的示例类
协议。它将将此 xml: 解析
为字典数组,每个字典都是 xml 中的一本“书”,其中包含每个标签的键以及该标签之间的文本作为键的值。因此,
[_delegate receiveParsedData:[returnData autorelease] withIdent:ident];
中的returnData
看起来像这样:JHXMLParser.h
JHXMLParser.m
Here's an example class implementing the
NSXMLParserDelegate
protocol.It would parse this xml:
into an array of dictionaries, each dictionary is a "book" from the xml with keys for each tag and the text between that tag as the value for the key. So this is how the
returnData
in[_delegate acceptParsedData:[returnData autorelease] withIdent:ident];
would look like:JHXMLParser.h
JHXMLParser.m