1

When using GDataXML* to build an XML document, how do I set the doctype of the generated XML? The rough outline of how I'm using GData can be found here:

http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml

Brandon DuRette
  • 4,810
  • 5
  • 25
  • 31
  • Unfortunately not. The documents we were generating were simple enough we built a single-purpose library for the specific document. – Brandon DuRette Jun 14 '11 at 15:33

1 Answers1

1

We ended up doing it this way, which is not ideal but does the trick:

NSMutableString* contentString = [[[NSMutableString alloc] init] autorelease];
[contentString setString:   @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"];
[contentString appendString:@"<!DOCTYPE somedoc SYSTEM \"http://x.y.com/some.dtd\">"];
[contentString appendString:@"<somedoc></somedoc>"];

GDataXMLDocument *document = [[[GDataXMLDocument alloc] initWithXMLString:contentString options:0 error:nil] autorelease];
Jim
  • 3,254
  • 1
  • 19
  • 26
  • Hi, do you know if it's possible upload a file, built in the way you described, on Gdocs converting it to doc format? – Sefran2 Jun 18 '11 at 15:29
  • @Fran: I'm not sure if I follow the question. Are you talking about uploading to Google Docs? GData is used for converting XML into a DOM based representation, which you can then manipulate, and stream out using String or NSData. What exactly are you looking to achieve? – Jim Jun 18 '11 at 16:02
  • Thanks for the replay. Really, I'm trying to upload an html with text and images, but I didn't succeed in neither embedding images with base64 encoding and in uploading images separately and then using the google https url in the html. So now I'm wandering in search of another solution, if any. – Sefran2 Jun 18 '11 at 16:33
  • @Fran: You can certainly, if creating the HTML yourself, use this for the solution, however you need to note HTML is only XML when it's strictly created. Trying to use other people's HTML as XML is a nightmare. If you were to use this you would use a method to create a hyperlink GDataXMLElement and add it to the DOC tree. You might also want to browse http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone – Jim Jun 18 '11 at 17:01
  • Sorry, I don't well understand your suggestion. However, is an xml doc converted on GDocs or not? I've not found a proper mime type allowed by GData API. – Sefran2 Jun 18 '11 at 17:12