Forum Moderators: open
Example:
<?xml version="1.0" encoding="iso-8859-1"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
>
<head>
<script language="JavaScript" type="text/javascript"> <![CDATA[
function load() {
//var frm = document.getElementById('svg_form');
frm.test.value = "The old radius is 100";
}
function circle_click() {
var fChild = document.getElementById('tr1');
document.getElementById("tr1").setData("Hello This is Hitesh");
fChild.setData("Hello This is Hitesh");
var circle = document.getElementById('c1');
var currentRadius = circle.getAttribute("r");
if (currentRadius == 100)
circle.setAttribute("r", currentRadius*2);
else
circle.setAttribute("r", currentRadius*0.5);
var n1 = circle.getAttribute("r")-0;
frm.test.value = "The new radius is " + n1 + " in html";
}
]]>
</script>
</head>
<body id="map" onload="load();">
<form id="svg_form">
<script> var frm = document.getElementById('svg_form');</script>
<table>
<tr id="tr1"></tr>
<tr>
<button onclick ="circle_click();">Change Radius</button>
</tr>
<tr>
<svg:svg id="svg1" width="400" height="400">
<svg:circle id="c1" cx="200" cy="200" r="100"/>
</svg:svg>
</tr>
<tr><td>
<input disabled="yes" size="30" style="border:0" type="text" name="test" value="Not loaded yet" readonly="no"/>
</td></tr>
</table>
</form>
</body>
</html>
If you look at the function circle_clk, you can see I tried to write something in the element "tr1" trying something like setData but no such action takes place because no such function exist. Which method will accomplish the same action as the function write() accomplish with HTML?
Can you tell me which methods work with XML as obviously the write() method doesn't work with XML?
Furthermore, can anyone refer me to a specification document listing all javascript methods that will work with XML?
document.getElementById('tr1').firstChild.nodeValue="Hello this is Hitesh".
It worked for me. Let me know if you have any problems. You can use the above method for setData() too. If you are wondering how I came to this solution, pls go to this XML DOM cheat sheet [xml.com].
Tedster, thanks for trying to help me. I appreciate it.