paxiinieintaxi
05-01-2004, 04:49 AM
hi.
i'm using the following Javascript-code to import a XML-file into my SVG-application:
...
getURL("./graph_xml_example.xml", my_callback);
...
function my_callback( urlRequestStatus ) {
if (urlRequestStatus.success)
{
alert('loaded stuff');
alert(urlRequestStatus.content);
xmlDoc = parseXML(urlRequestStatus.content, null);
// null -> create a new XML doc
alert(xmlDoc);
var xmlRoot = xmlDoc.getDocumentElement();
alert(xmlRoot);
var node3 = xmlDoc.getElementById("masterblaster");
alert(node3);
var label3 = node3.getAttribute("label");
alert(label3);
}
else
{
alert('nuttin\' loaded');
}
}
loading the XML-file works fine so far, but I can't work with the XML-file.
alert(xmlDoc) gives: [object Document]
that's ok, I suppose :P
alert(xmlRoot) gives: [object Element]
seems to be ok as well, but I don't know what I could do with that xmlRoot anyway
alert(node3) gives: null
that means, the node with the id "masterblaster" wasn't found, although it exists:
<?xml version="1.0"?>
<!DOCTYPE graph PUBLIC "-//John Punin//DTD graph description//EN" "http://www.cs.rpi.edu/~puninj/XGMML/xgmml.dtd">
<graph directed="1" graphic="1" Layout="points">
<fuckit id="masterblaster" label="whatever"/>
<node id="1" label="Node 1" weight="0">
<graphics type="rhombus" x="270" y="90" ></graphics>
</node>
<node id="2" label="node 2" weight="0">
<graphics type="ver_ellipsis" x="350" y="190" ></graphics>
</node>
<edge source="1" target="2" weight="0" label="Edge from node 1 to node 2" ></edge>
</graph>
The attempt to get the label of node3 obviously fails as well.
Hints, anyone? :)
tia,
moritz
i'm using the following Javascript-code to import a XML-file into my SVG-application:
...
getURL("./graph_xml_example.xml", my_callback);
...
function my_callback( urlRequestStatus ) {
if (urlRequestStatus.success)
{
alert('loaded stuff');
alert(urlRequestStatus.content);
xmlDoc = parseXML(urlRequestStatus.content, null);
// null -> create a new XML doc
alert(xmlDoc);
var xmlRoot = xmlDoc.getDocumentElement();
alert(xmlRoot);
var node3 = xmlDoc.getElementById("masterblaster");
alert(node3);
var label3 = node3.getAttribute("label");
alert(label3);
}
else
{
alert('nuttin\' loaded');
}
}
loading the XML-file works fine so far, but I can't work with the XML-file.
alert(xmlDoc) gives: [object Document]
that's ok, I suppose :P
alert(xmlRoot) gives: [object Element]
seems to be ok as well, but I don't know what I could do with that xmlRoot anyway
alert(node3) gives: null
that means, the node with the id "masterblaster" wasn't found, although it exists:
<?xml version="1.0"?>
<!DOCTYPE graph PUBLIC "-//John Punin//DTD graph description//EN" "http://www.cs.rpi.edu/~puninj/XGMML/xgmml.dtd">
<graph directed="1" graphic="1" Layout="points">
<fuckit id="masterblaster" label="whatever"/>
<node id="1" label="Node 1" weight="0">
<graphics type="rhombus" x="270" y="90" ></graphics>
</node>
<node id="2" label="node 2" weight="0">
<graphics type="ver_ellipsis" x="350" y="190" ></graphics>
</node>
<edge source="1" target="2" weight="0" label="Edge from node 1 to node 2" ></edge>
</graph>
The attempt to get the label of node3 obviously fails as well.
Hints, anyone? :)
tia,
moritz