Why can't I update the value of a node in my XML file? I can add new nodes with values to the file with "dom createNodeCmd" command, but changing values in the file doesn't work. I get the "NO_MODIFICATION_ALLOWED_ERR" error on the line " $node nodeValue "10000" ". Does anybody have a clue of what might be wrong?
Thanx in advance..
The structure of it is as follows.
# FILE
# CODE
Thanx in advance..
The structure of it is as follows.
# FILE
Code:
<projects>
<project>
<id>10024</id>
<date>2004-08-11</date>
</project>
<project>
<id>10235</id>
<date>2004-08-11</date>
</project>
<project>
<id>10021</id>
<date>2004-08-11</date>
</project>
<project>
<id>10214</id>
<date>2004-08-11</date>
</project>
</projecs>
# CODE
Code:
# Open a XML file for read/write
# xmlfile - contents of xml file
# fid - channel id of file
# id = 10214
# Create a tDOM doc from file
set doc [dom parse $xmlfile]
# Set root tag
set root [$doc documentElement]
# Update project data
# -------------------
foreach projectNode [$root childNodes] {
# If project_id matches node
puts "If project_id matches node"
if {[string match -nocase $id [[$projectNode selectNodes id] text]]} {
# <id>
set node [$projectNode selectNodes id]
$node nodeValue "10000"
break
}
}
# Write XML to file
puts $fid [$root asXML]
# Close channel to file
close $fid