Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

How to create a xml file dynamically

sapplesapple Posts: 13Registered Users
Hi

I want to create a xml file dynamically using xcode. Can any one suggest me how can I do it?

Thanks in advance :(

Gaurav
Post edited by sapple on

Replies

  • ErleErle Posts: 18Registered Users
    Hey had the same problem during an University Project, I solved it with a Class putting together a string containing XML data
    Individual iPhone Developer with own company

    "Mettigel Software"

    =======================

    My Apps:

    Zebrafans 0.99$

    <a href="http://itunes.com/app/li
  • sapplesapple Posts: 13Registered Users
    Hey can you please send me that code.

    Thanks in advance

    Gaurav
  • ErleErle Posts: 18Registered Users
    sapple;147380 said:
    Hey can you please send me that code.

    Thanks in advance

    Gaurav
    No Problem, there it is, I will also post that on my Homepage later.

    XMLBuilder.h
    //
    // XMLBuilder.h
    // TaxiSharing
    //
    // Created by Erle on 02.07.09.
    // Copyright 2009 University of Duisburg-Essen,
    // Institute of Computer Science and Business Computer Science
    // Group for Pervasive Computing and User Interface Engineering
    // All rights reserved.
    //

    #import <Foundation/Foundation.h>


    @interface XMLBuilder : NSObject {
    NSMutableString *XMLString;

    }

    @property(nonatomic,retain) NSMutableString *XMLString;

    -(void)addTagToXML:(NSString *)tag withValue:(NSString *)value;
    -(void)addSelfClosedTag:(NSString *)tag withInnerValueTitle:(NSString *)innerValueTitle andValue:(NSString *)value;
    -(void)addSelfClosedTag:(NSString *)tag withInnerString:(NSString *)innerString;
    -(void)addSingleTag:(NSString *)tag withInnerString:(NSString *)innerString;
    -(void)addSingleValue:(NSString *)value;
    -(void)addSingleTag:(NSString *)tag;
    -(void)endSingleTag:(NSString *)tag;
    -(void)closeXML;

    @end

    //
    // XMLBuilder.m
    // TaxiSharing
    //
    // Created by Erle on 02.07.09.
    // Copyright 2009 University of Duisburg-Essen,
    // Institute of Computer Science and Business Computer Science
    // Group for Pervasive Computing and User Interface Engineering
    // All rights reserved.
    //

    #import \"XMLBuilder.h\"


    @implementation XMLBuilder

    @synthesize XMLString;

    -(id)init{
    [super init];
    XMLString = [[NSMutableString alloc] initWithFormat:@\"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?> \n\"];
    return self;
    }

    -(void)addTagToXML:(NSString *)tag withValue:(NSString *)value{
    [XMLString appendFormat:@\"<%@>%@</%@> \n\",tag,value,tag];
    }

    -(void)addSelfClosedTag:(NSString *)tag withInnerValueTitle:(NSString *)innerValueTitle andValue:(NSString *)value{
    [XMLString appendFormat:@\"<%@ %@=%@ /> \n\",tag,innerValueTitle,value];
    }

    -(void)addSelfClosedTag:(NSString *)tag withInnerString:(NSString *)innerString{
    [XMLString appendFormat:@\"<%@ %@ /> \n\",tag,innerString];
    }

    -(void)addSingleTag:(NSString *)tag withInnerString:(NSString *)innerString{
    [XMLString appendFormat:@\"<%@ %@ > \n\",tag,innerString];
    }
    -(void)addSingleValue:(NSString *)value{
    [XMLString appendFormat:@\"%@ \n\",value];
    }

    -(void)addSingleTag:(NSString *)tag{
    [XMLString appendFormat:@\"<%@> \n\",tag];
    }

    -(void)endSingleTag:(NSString *)tag{
    [XMLString appendFormat:@\"</%@> \n\",tag];
    }

    -(void)closeXML{
    [XMLString appendFormat:@\"\n\"];
    }

    -(void)dealloc{
    [super dealloc];
    [XMLString release];
    }
    @end
    Individual iPhone Developer with own company

    "Mettigel Software"

    =======================

    My Apps:

    Zebrafans 0.99$

    <a href="http://itunes.com/app/li
Sign In or Register to comment.