在Iphone中动态创建XML文件 [英] Create XML file dynamically in Iphone

查看:135
本文介绍了在Iphone中动态创建XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的Iphone应用程序动态创建一个xml文件。我尝试使用NSXMLDocument,但未在iphone应用程序中声明NSXMLDocument。

I want to create a xml file dynamically for my Iphone application. I tried it by using NSXMLDocument but NSXMLDocument is not declared in iphone application.

请帮助我这样做。

谢谢

Gaurav

推荐答案

试试开源适用于iOS的XML流编写器


  • 用Objective-C编写,单个.h。和.m文件

  • 一个@protocol用于命名空间支持,一个用于没有

示例:

// allocate serializer
XMLWriter* xmlWriter = [[XMLWriter alloc]init];

// start writing XML elements
[xmlWriter writeStartElement:@"Root"];
[xmlWriter writeCharacters:@"Text content for root element"];
[xmlWriter writeEndElement];

// get the resulting XML string
NSString* xml = [xmlWriter toString];

这会产生以下XML字符串:

This produces the following XML string:

<Root>Text content for root element</Root>

这篇关于在Iphone中动态创建XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆