Subj : Spidermonkey: Simple parsing of JS in XML files To : netscape.public.mozilla.jseng From : Andreas Granig Date : Wed Jun 08 2005 12:22 am Hi all, I'm completely new to spidermonkey, so maybe someone can clear some points for me before I start coding: I need to parse a xml file which may for example look like the following snipped, where for an element named "myelem" the "name" attribute should be handled as javascript object name and the "value" attribute as javascript code: As what I have read from spidermonkey documentation, I'd just perform the following steps (pseudo code, error handling omitted): JSRuntime *rt = JS_NewRuntime(...); JSContext *cx = JS_NewContext(rt, ...); // init standard classes here... // in the script-callback called by dom parser { // ... string script = element.getvalue(); JSBool ok = JS_EvaluateScript(cx, globalObj, script.c_str(), script.length(), "script", lineno, &rval); } // in the myelem-callback called by dom parser { // get values for name- and value-attributes: string objName = domparser.getname(); string objValue = domparser.getvalue(); JS_DefineObject(cx, obj, objName, ...); // or maybe JS_NewObject, don't know right now } Is this basically correct? Or do I have to watch out for some basic pit falls which could occure here? Are there some beginners resources I could use as a reference for parsing and interpreting JS in xml/html (beside the Mozilla-code ;o) Thanks alot, Andy .