我在 ios 中创建 xml,这是正确的(在日志上打印),但是当我将xmlDocument
in转换为时NSString
,字符串包含 null 当我在日志中打印时,需要 sting 作为 webservice 的参数,如何分配xmlDocument
给NSString
...谢谢..
我的代码是...
GDataXMLElement *rootElement = [GDataXMLElement elementWithName:@"Root"];
GDataXMLElement *zipCode = [GDataXMLElement elementWithName:@"zipCode" stringValue:self
.tfZipcode.text];
GDataXMLElement *phoneNo = [GDataXMLElement elementWithName:@"phoneNo" stringValue:self.tfPhone.text];
GDataXMLElement *cellNo = [GDataXMLElement elementWithName:@"cellNo" stringValue:self.tfCell.text];
GDataXMLElement *city = [GDataXMLElement elementWithName:@"city" stringValue:self.tfCity.text];
GDataXMLElement *zone = [GDataXMLElement elementWithName:@"zone" stringValue:self.tfZone.text];
GDataXMLElement *firstName = [GDataXMLElement elementWithName:@"firstName" stringValue:self.tfFirstName.text];
GDataXMLElement *lastName = [GDataXMLElement elementWithName:@"lastName" stringValue:self.tfLastName.text];
GDataXMLElement *address = [GDataXMLElement elementWithName:@"address" stringValue:self.tfAddress.text];
GDataXMLElement *email = [GDataXMLElement elementWithName:@"email" stringValue:self.tfEmail.text];
GDataXMLElement *service = [GDataXMLElement elementWithName:@"service" stringValue:self.tfService.text];
GDataXMLElement *product = [GDataXMLElement elementWithName:@"product" stringValue:self.tfProduct.text];
GDataXMLElement *symptom = [GDataXMLElement elementWithName:@"symptom" stringValue:self.tfSymptoms.text];
GDataXMLElement *jobType = [GDataXMLElement elementWithName:@"jobType" stringValue:self.tfJobType.text];
GDataXMLElement *ref = [GDataXMLElement elementWithName:@"ref" stringValue:self.tfRef.text];
GDataXMLElement *reqDate = [GDataXMLElement elementWithName:@"reqDate" stringValue:self.tfDateTime.text];
[rootElement addChild:zipCode];
[rootElement addChild:phoneNo];
[rootElement addChild:cellNo];
[rootElement addChild:city];
[rootElement addChild:zone];
[rootElement addChild:firstName];
[rootElement addChild:lastName];
[rootElement addChild:address];
[rootElement addChild:email];
[rootElement addChild:service];
[rootElement addChild:product];
[rootElement addChild:symptom];
[rootElement addChild:jobType];
[rootElement addChild:ref];
[rootElement addChild:reqDate];
GDataXMLDocument *xml = [[GDataXMLDocument alloc] initWithRootElement:rootElement];
NSLog(@"%@", [xml rootElement]); // print xml on log
NSString *stringXml = [xml rootElement];
NSLog(@"%@",stringXml);