modify XML document

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a document XML that I would modify in VisualBasic.NE
When the user set the checkbox and radiobutton in a form I save this information and modify a document
My document is in the following form

<opzioni><opzione nome="DDR"><item tipo="prova" label="Ridotto">true</item><item tipo="completo" label="ok">false</item></opzione><opzione nome="SDR"><item tipo="speed" label="Veloce">true</item><item tipo="normal" label="Normale">false</item></opzione></opzioni

I have to modify the value True/False into the TAG <item

xmlDoc.Load(fileName
root = xmlDoc.DocumentElemen
nodeList = root.SelectNodes("opzione/item"
For I = 0 To nodeList.Count -
elem = nodeList.Item(I
elem.Value = NEWVALUE ****My code generate an error here***

This is the error messagge:
"Impossibile impostare un valore su un nodo di tipo: Element.

thank yo
cos75
 
Use node.InnerText instead of node.Valu

By the way, I had to get BabelFish to hep me with your error message.
 
hmm.. Two different answers, that's nice

If we have the following XML-cod

<opzione nome="SDR"><item tipo="speed" label="Veloce">test1<child>ab</child>test2</item></opzione

InnerText would return
test1abtest

InnerXml would return
test1<child>ab</child>test

Setting XML with InnerText or InnerXml makes no difference as long as there are no XML-tags (<child></child>
InnerText will screw these tags (&lt,&gt)

In the given case there's no difference.
 
ok but now I have lost every attribute on the tag ite


----- Marinus Holkema wrote: ----

Change the line wich generated the error into

elem.InnerXml = NEWVALU

Marinus
 
I changed the line in elem.value=false.ToString()

other assumptions
root as XmlElemen
nodelist as XmlNodeLis
xlmDoc as XmlDocumen
elem as XMLNod

the resulting xml was

<opzioni><opzione nome="DDR"><item tipo="prova" label="Ridotto">False</item><item tipo="completo" label="ok">False</item></opzione><opzione nome="SDR"><item tipo="speed" label="Veloce">False</item><item tipo="normal" label="Normale">False</item></opzione></opzioni

Any differences?
 
Back
Top