I just happened to learn abt xml DOM.....I tried this script and run it bt didnt get the desired result..I expected to get the value I attached to my code node bt what I gt ws null which means that I went wrong somewhere in my script....
This is the script....!!!!
I went wrong somewhere in my codes bt cant guess where....
Can u tell me where I went wrong and how can I attach a value to a node ??
Thanks in adv
With regards
phpuser123
Code:
<html>
<head>
<script type='text/javascript'>
xml_modules="<modules><module><code></code></module></modules>";
var xml_modules;
function addxml(url)
{
var xmlDoc;
try{
xmlDoc=new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async='false';
xmlDoc.loadXML(url);
return xmlDoc;
}
catch(e){
try {
parser=new DOMParser();
xmlDoc=parser.parseFromString(url,'text/xml');
xmlDoc.encoding='UTF-8';
return xmlDoc;
}catch(e) {alert(e.message);}
}
return (null);
}
var xml_Doc_modules=addxml(xml_modules);
function textxml()
{
root=xml_Doc_modules.childNodes[0];
a=xml_Doc_modules.createTextNode('node1');
root.childNodes[0].childNodes[0].appendChild(a) ;
alert(root.childNodes[0].childNodes[0].nodeValue);
}
</script>
</head>
<body>
<button onclick='textxml()'>ProcessXml</button>
</body>
This is the script....!!!!
I went wrong somewhere in my codes bt cant guess where....
Can u tell me where I went wrong and how can I attach a value to a node ??
Thanks in adv
With regards
phpuser123
Comment