Just like in the question. For example I make a request and get a html document with multiple td tags, how to retrieve the data? Do I need to learn regex?
Asked
Active
Viewed 18 times
0
-
do you receive document in string format? – semanser Jul 16 '16 at 15:51
-
Do you want to read a specific HTML tag information? – prodeveloper Jul 16 '16 at 15:51
-
if you want to display the html obtained in the current document, you can append it with jQuery library – Alfredo EM Jul 16 '16 at 15:52
-
@semanser yes, a string, do you recommend using jQuery like Alfredo EM suggested? – youbetternot Jul 16 '16 at 15:54
-
@youbetternot yes, you can use jQuery. Also you can check this question: http://stackoverflow.com/questions/10585029/parse-a-html-string-with-js – semanser Jul 16 '16 at 15:57
-
thanks guys, you put me on a right path and I've found https://www.npmjs.com/package/cheerio – youbetternot Jul 16 '16 at 16:17
1 Answers
0
No, you don't need a regex. You can use https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/HTML_in_XMLHttpRequest to get a DOM object, which you can query by the usual methods (CSS selectors, XPath, manual tree walking, etc).
There's also DOMParser for when you only have an HTML string.

melpomene
- 84,125
- 8
- 85
- 148