Js gets the value of an input in the string returned by ajax

scenario is the background js script of chrome browser. Ajax requests to get a html string. Except for regular matching, there is no way to get the value attribute of an input in the string
.
Mar.20,2021

create a Dom node ParentNode.
mount the acquired html to the dom node by ParentNode.append (htmlString)
find the value.


regular matching of the corresponding node


you can also use xml analysis library, because html is a special xml, as long as you know the specific xml analysis search path, you can extract node values or node attributes.


write an analysis tool and analyze it tag by tag, which is much more accurate than the regularization.


several bigwigs upstairs. Now that the subject has said that it is Chrome, there is no need to look for the wheel. The rules / tools are also written by themselves, and the fancy takeoff is also required when it comes to bug. (anyway, I've never written an one-off [sadness])

DOMParser learn about https://developer.mozilla.org.

.
const parser = new DOMParser();
const doc = parser.parseFromString(response, "text/html")

then getById , getByTagName , take your pick.

Menu