title: Problems writing to an XML file in Xcode
body: <p>I created a client-server restaurant project in which I read from an XML file. But I need to write and update the XML file. I faced a lot of problem when I write XML .
  I searched various websites and forums, but I could not found any solutions. Please help me if anyone knows how to do this.</p>
  
  <p>I wrote the following code to create a sample project which I found from a tutorial.
  But some errors occur when I build:</p>
  
  <blockquote>
    <p>Error:NSXMLDocument , NSXmlNode  undeclared</p>
  </blockquote>
  
  <p>I tried adding the Cocoa framework to solve this, but it didn't seem to work.</p>
  
  <pre><code>- (NSData *)constructXMLRequest
  {
      NSXMLElement *root = [[NSXMLElement alloc] initWithName:@"Request"];
      [root addAttribute:[NSXMLNode attributeWithName:@"Attribute1" stringValue:@"Value1"]];
      [root addAttribute:[NSXMLNode attributeWithName:@"Attribute2" stringValue:@"Value2"]];
      [root addAttribute:[NSXMLNode attributeWithName:@"Attribute3" stringValue:@"Value3"]];
  
      NSXMLElement *childElement1 = [[NSXMLElement alloc] initWithName:@"ChildElement1"];
      [root addChild:childElement1];
      [childElement1 release];
  
      NSXMLElement *childElement2 = [[NSXMLElement alloc] initWithName:@"ChildElement2"];
      [childElement2 addAttribute:[NSXMLNode attributeWithName:@"ChildAttribute2.1" stringValue:@"Value2.1"]];
      [childElement2 setStringValue:@"ChildValue2.1"];
      [root addChild:childElement2];
      [childElement2 release];
  
      NSXMLDocument *xmlRequest = [NSXMLDocument documentWithRootElement:root];
      [root release];
      NSLog(@"XML Document\n%@", xmlRequest);
      return [xmlRequest XMLData];
  }
  </code></pre>