First I added 2 properties in the plist as
4. Added a extension as
In this case I'm able to upload a file but not unable to parse the file is there some way to parse the file and get the content inside the xml file
Support opening documents in place = YES
Application supports iTunes file sharing = YES
Then Created a button to upload the xml file
Code Block @IBAction func didTapUploadFile(_ sender: Any) { let documentPicker = UIDocumentPickerViewController(documentTypes: [kUTTypeItem as String], in: .import) documentPicker.delegate = self documentPicker.allowsMultipleSelection = false present(documentPicker, animated: true, completion: nil) }
4. Added a extension as
Code Block extension ViewController: UIDocumentPickerDelegate { func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let selectedFileUrl = urls.first else { return } let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let sandboxFile = dir.appendingPathComponent(selectedFileUrl.lastPathComponent) if FileManager.default.fileExists(atPath: sandboxFile.path) { print("File Already\(config)") } else { do { let contentFile = try NSString(contentsOf: selectedFileUrl, encoding: String.Encoding.utf8.rawValue) config = contentFile as String print("File Upload\(config)") } catch { print("Error \(error)") } } } }
In this case I'm able to upload a file but not unable to parse the file is there some way to parse the file and get the content inside the xml file