Parsing a WSDL file like XML? - ios

I'm receiving a file from a server, but instead of being an xml file it is a wsdl file with the same exact text that would be in an xml file. Since the content is the exact same can I parse it as if it were an xml file? Or do I need to convert it somehow?

WSDL is in fact a XML to describe and locate web services. It is not the content itself. Even though technically you can parse it, you should expect a XML file from server.

Related

Swift - how do i convert a regular XML file to a .plist XML file

I searched the web for this one and mostly found Obj-C answers or outdated answers so ill simply post the question and hope for the best :)
Im working with a team of Android Developers while im working on IOS. they use XML files for a lot of data. since we want the data between us to stay consistent - we want to be able to have shared XML files to use in our projects.
I know .plist is basically a type of XML, but i want to be able to get the regular shared XML file and turn it into a .plist and then use it in my IOS project.
any known method of doing it at all? if so, is it possible to do it automatically somehow? (script or something of that sort. maybe even do it locally inside the application)
Thanks for the help
A .plist file is a very specific XML file with only a small set of keys allowed. A random XML file will not be convertible to a .plist file.
Try converting your file to JSON first. If you can convert it to JSON you will be able to automatically convert it to a .plist after that using the plutil command with the xml1 or binary1 format.
plutil -convert xml1 -o output.plist input.json
If you can't convert it to JSON, you can keep your XML file as is and parse it in your app using NSXMLParser. XML is harder to parse than .plist or JSON files, but aside from that the difference should be minimal.

Generate JSON file from Xcdatamodel

Is it possible to generate JSON file from xcdatamodel?
Here's how I imagine it would work: Given a xcdatamodel file, going through some program with some custom logic (will probably be written by me), will generate JSON file for me to use in third-party library. My question: Is this possible? Has anyone ever done it?
The content of xcdatamodel is a content file with xml data and as bin file (no extension) so now it is easy to parse xml to json.

MIME Type is changing my file extension

I'm working on an app that allows files to be opened from both the email application Apple provides, and the web. The problem is when I email myself a file, the extension clearly shows it's a .gfp file. But the minute I download it to my computer it turns into a .json file. The .gfp file is using JSON to organize the data, but it's not supposed to be a .json file. I understand that it's the MIME type screwing it up, but I can't leave the MIME type nil, meaning I'm stuck with a preexisting filetype. How do I keep it a .gfp file no matter where it goes?
Code:
[mailer addAttachmentData:jsonData mimeType:#"application/json" fileName:[NSString stringWithFormat:#"%#.gfp", objectName.stringThing]];
I've tried changing the application/json to something like a little more broad like text/plain but then it morphs into a .txt file when transferred to a computer.

On malformed files

Suppose you start looking at an XML file, which you parse and confirm that it in fact an XML file. Life is good.
Then someone removes a > somewhere in a file, which effectively makes the file a malformed XML from parser's stand point. As far as it's concerned, the file is no longer a properly formed XML file.
Is there a way one can one confirm that file is in fact still an XML file, albeit a malformed one?
The question extends beyond XML (obviously). How can one arrive at a conclusion that a file is "probably of a certain type", as opposed "i can't parse it and therefore it is certainly not of a certain type"?

XMl Data into String in blackberry

Read the contents of an local XML file in an application and get the whole contents of xml file into a string for blackberry application?
To create a string from a local file see this blackberry forum entry: Open txt file from mediacard
Assuming you want to use the data within the XML, I would recommend using a XML parser rather than string manipulation. The following links should get you going with XML parsers and explain some of the trade-offs:
Blackberry How To - Use the XML Parser
Parsing XML in J2ME
Add XML parsing to your J2ME applications
If, however, you have any say about the format used JSON might be a good alternative. JSON is easy for machines to parse (thus using fewer resources) and it's human readable.
I have found using a SAXParser and subclassing DefaultHandler has worked well. Allows to go element by element.

Resources