Generate XML-String dynamically from NSObjects

ptthanh

New Member
I am trying to dynamically generate one single XML-String with the attributes of one or more NSObjects.I am using WonderXML but I do not understand how I am able to adjust the structure of the XML-Strings that WonderXML produces.Here is my code so far:Object:\[code\]@interface Getraenke_Object : NSObject { @protected NSString *item_id; NSString *menge; NSString *categorie; NSString *name; NSString *preis; NSString *image; }@property (nonatomic, copy) NSString *item_id;@property (nonatomic, copy) NSString *menge;@property (nonatomic, copy) NSString *categorie;@property (nonatomic, copy) NSString *name;@property (nonatomic, copy) NSString *preis;@property (nonatomic, copy) NSString *image;@end\[/code\]m-File:\[code\]//-----------------Converting the Objects to XML-Strings-------------- XmlParser *parser = [[XmlParser alloc] init]; NSString *meinXmlString; for(int i=0; i<getraenkeArray.count; i++) { meinXmlString = [parser toXml:[getraenkeArray objectAtIndex:i] andTag:@"Getraenk" inNameSpace:@"table_info"]; } NSLog(@"meinXmlString: %@\n", meinXmlString);\[/code\]This is how meinXmlString looks like:meinXmlString: \[code\]<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Getraenke_Object xmlns="table_info"><name>Chateau_d_Angludet</name><menge>1</menge><preis>119</preis><image>Rotwein.png</image><categorie>getraenke</categorie><item_id>101</item_id></Getraenke_Object>\[/code\]but it should look like:testXML: \[code\]<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Table_info><table_id>1</table_id><action_id>3</action_id><Bestellliste><item><categorie>getraenke</categorie><item_id>100</item_id><menge>1</menge></item><item><categorie>getraenke</categorie><item_id>2</item_id><menge>1</menge></item></Bestellliste></Table_info>\[/code\]I hopefully described my problem understandable.Thanks!
 
Back
Top