/    Sign up×
Community /Pin to ProfileBookmark

Problem manupulating XML using JavaScript DOM.

Hi

I am working on a DHTML task where i need to manupulate a XML File content where i need create a extra attribute for some Xml Node in a XMLNodeList.I am doing all this thing using xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);

But after all manupulation is done i am not getting the changes in the Original XML file which is residing in my local Disk.

tHE Code as follows

[code]
function ExtractDataFromXML()
{

try
{

var ambAmb =Window.External; // calling my C# EXTERNAL class from a webbroser control
var CycleId = “1”;
var searchCycle = “//cycle[@cid = ” + ‘”‘ + CycleId + ‘”‘ + “]”;
var vals=ambAmb.CreateAndParseXMLDoc(); //vals is the path of xml document in the diskfile like c:demo.xml
xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);

xmlDoc.async=”false”;
try
{

xmlDoc.load(vals.toString()); //

var rootElement = xmlDoc.firstChild;

var objCycle = rootElement.selectSingleNode(searchCycle);

var objWorksheets = objCycle.selectNodes(“.//worksheet”);

var objWorksheet;
var currentGuid;
//var dt = new Date();
//var fmtDate = formatDate(dt, “MM/dd/yyyy hh:mm:ss”);

for (i=0; i<objWorksheets.length; i++) {
var newatt=xmlDoc.createAttribute(“deleteddate”);
newatt.nodeValue=”xyz”;
objWorksheet = objWorksheets.item(i);
objWorksheet.setAttributeNode(newatt);

}

alert(“Done”);
[/code]

But the problem is that No changes takes place in physical path and when i try to put xmlDoc.save() or xmlDoc.save(vals) it showing object error.

Can anybody tell me what i am doing wrong here.

Thanks

__Das

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @das_dwipayan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...