AndroidBoy
AndroidBoy

Reputation: 35

Try to parse html table in iOS

I'm new in swift/iOS and I looking for best way to parse html table without WebView and display it on the screen. It is possible to do it with NSMutableAttributedString or NSAttributedString

Upvotes: 0

Views: 640

Answers (1)

arun siva
arun siva

Reputation: 869

You can display the HTML table using UITextView.

@IBOutlet weak var textView: UITextView!
override func viewDidLoad() {
    super.viewDidLoad()
    if let data = htmlString.data(using: String.Encoding.unicode),
        let attString = try? NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html], documentAttributes: nil) {
        lbl.attributedText = attString
        textView.attributedText = attString
    }
}

Upvotes: 1

Related Questions