I want to parse HTML using Jquery
I am getting some HTML from server as responseText like this :
<html>
<title>Title</title>
<body>
<p>My JSON data</p>
</body>
</html>
Now 开发者_开发技巧i want to parse this using jquery parseJSON function, How could i do this plz help me.
Thanks
parseJSON
is for parsing json
if you are getting a valid html from the server then you can apply jquery's simple DOM traversal methods to it and get the desired object, or you can also use
.parseXML
to parse the html if it contains some non standard html tags
If you simply create a jQuery object with the responseText, it will return a representation of the content in the body of your responseText, e.g.
var jqobj = $('<html><head></head><body><p>Meep</p></body></html>');
var text = jqobj.html(); // returns "Meep"
Then you can parse it.
精彩评论