wozoi
06-15-2003, 10:29 AM
hi,
i'm a beginner i'm trying to access variable stored in an xml file from a javascript function embedded in a svg file. I ll repeat, i'm trying to access variable stored in an xml file from a javascript function embedded in a svg file.
and i don't wanna use an activeX controler.
I think it's possible to start like this, but it's the first time i manipulate XML so i'm a little bit inexperienced (forgive me before reading ;))
the xml source call sourceParam.xml :
<?xml version="1.0"?>
<varSource>
<mode> create</mode>
<todo>draw</todo>
<form>territory</form>
<envDraw>mondial</envDraw>
<drawingFrom>taiga</drawingFrom>
</varSource>
then in a initialize function of the javascript file :
getURL ("sourceParam.xml",getParam);
and the getParam function :
function getParam( data )
{
if (data.success)
{
var doc_frag = parseXML ( data.content, svgdoc);
childs=doc_frag.getChildNodes();
var mode=childs.childNodes(1).firstChild.text;
var todo=childs.childNodes(2).firstChild.text;
var form=childs.childNodes(3).firstChild.text;
var envDraw=childs.childNodes(4).firstChild.text;
var drawingForm=childs.childNodes(5).firstChild.text;
}
else {alert ("Error reading file");}
}
My objective is to instanciate the variables according to the xml file, please help me to find this solution.
thanks,
wozoi
i'm a beginner i'm trying to access variable stored in an xml file from a javascript function embedded in a svg file. I ll repeat, i'm trying to access variable stored in an xml file from a javascript function embedded in a svg file.
and i don't wanna use an activeX controler.
I think it's possible to start like this, but it's the first time i manipulate XML so i'm a little bit inexperienced (forgive me before reading ;))
the xml source call sourceParam.xml :
<?xml version="1.0"?>
<varSource>
<mode> create</mode>
<todo>draw</todo>
<form>territory</form>
<envDraw>mondial</envDraw>
<drawingFrom>taiga</drawingFrom>
</varSource>
then in a initialize function of the javascript file :
getURL ("sourceParam.xml",getParam);
and the getParam function :
function getParam( data )
{
if (data.success)
{
var doc_frag = parseXML ( data.content, svgdoc);
childs=doc_frag.getChildNodes();
var mode=childs.childNodes(1).firstChild.text;
var todo=childs.childNodes(2).firstChild.text;
var form=childs.childNodes(3).firstChild.text;
var envDraw=childs.childNodes(4).firstChild.text;
var drawingForm=childs.childNodes(5).firstChild.text;
}
else {alert ("Error reading file");}
}
My objective is to instanciate the variables according to the xml file, please help me to find this solution.
thanks,
wozoi