Hi ...
a bit stuck with this ...
in my case, I want to replace the old value with a new value via Dotnet
this is XML view

the value of the sphere is a target to be changed
what I want to do is simple,... replace a "sphere" value with a "plane"
--------------------------------------------------------------------------------------------------- Initial
--Load the xml assembly
dotNet.loadAssembly "system.xml"
--Create an xml document object.
xmlDoc=dotNetObject "system.xml.xmlDocument"
--Open the file in Max to see the file.
filename="C:\\BGtest.xml" -- ((getDir #autoback)+"\\BGtest.xml")
--------------------------------------------------------------------------------------------------- Load document
--Load the XML file.
xmlDoc.load filename
--------------------------------------------------------------------------------------------------- read document
--Check to make sure the xmlDoc has a root element.
docEle=xmlDoc.documentElement
clearListener()
format "Element Name: %\n\n" docEle.name
--Check a target attribute value called name
objNameStr=(docEle.ChildNodes.itemOf[0].GetAttributeNode "name").value
format "Node Name: %\n\n" objNameStr
--Check a target attribute value called class
objClassStr=(docEle.ChildNodes.itemOf[0].GetAttributeNode "class").value
format "Node class: %\n\n" objClassStr
--------------------------------------------------------------------------------------------------- Manipulate document
--Want to replace "sphere" to "Plane" but it's doesn't work correctly
docEle.ChildNodes.itemOf[0].SetAttributeNode "name" "Plane001" --$.name
docEle.ChildNodes.itemOf[0].SetAttributeNode "class" "Plane" --classOf $ as string
--------------------------------------------------------------------------------------------------- save and open document
xmlDoc.save filename
edit filename -- to see the result
so i tried but still not working
any suggestion ?
attached example xml...
thanks
By Budi G · 2013-09-17
barigazy · 2013-09-18