Recently I am studying ajax. I can generate an xml document on the server and return it to the front-end.
Xml documents are obtained by xmlHttp. responseXML at the front end.
Assume that the xml document I generated is as follows:
<User>
<Name> jack </name>
<Age> 12 </age>
<Address> beijing </address>
<Date> 2007/03/20 </date>
</User>
Can the foreground dynamically generate a class after obtaining this document? The code for this class is as follows:
Function User (){
Var name;
Var age;
Var address;
Var date;
}
And save the xml document data to the User object. Can JavaScript experts implement this?
1. jsObject. text = xxx
2. eval (xxx)
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <meta name = "Generator "CONTENT =" EditPlus "> <meta name =" Author "CONTENT =" "> <meta name =" Keywords "CONTENT =" "> <meta name =" Description "CONTENT = ""> </HEAD> <BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
If you want to construct a class, use eval to return the class, instead of returning the object.
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]