2

I am creating one app that downloads HTML file from server. I am storing that file in local storage for offline usage. I have requirement to parse data from that file. I can do it by parsing the HTML tags, but I want to make is standard way hence JSON-LD is a good way to do it using HTML5. So anytime the HTML structure changes, I would not have to update code.

I want to read JSON-LD data from HTML file in Objective-C. I googled it but not found any pretty way to read it.

Should I have to read it same way like reading HTML string from file? Can anyone please guide me, if there is any specific way to do it?

1 Answer 1

3

I have parsed JSON-LD model from HTML file using following way,

  1. Get Any XMLParser/HTMLParser Dictionary. (I used https://github.com/nicklockwood/XMLDictionary).

  2. converted content of HTML file into NSDictionary using XMLParser dictionary.

    var maindic = NSDictionary(XMLFile:NSBundle.mainBundle().pathForResource("JSON-LD_Sample_Card", ofType: "html"))

Then from dictionary we can easily get array of different tags and there we can parse JSON-LD script Tag too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.