SoFunction
Updated on 2025-02-28

Dynamically generate js class implementation method

Recently I am studying ajax problem, I can generate an XML document on the server side and return it to the front desk
Obtain xml documentation from the front desk
If 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 a class be generated dynamically after the front desk obtains this document? The code of this class is as follows
function User(){
   var name;
   var age;
   var address;
   var date;
}
And save the data of the xml document into the User object accordingly. Is there any way for all the experts in js to implement this?

1.  =xxx
2.  eval(xxx)