Updating XML Tag Values using VB.NET -


i need update below xml using vb.net code. tags added , need update value.

<?xml version="1.0" encoding="utf-8"?>     <test xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">         <language>eng</language>         <statement/>         <statement2/>         <statement3/>         <size/>         <language>fra</language>         <statement/>         <statement2/>         <statement3/>         <size/>         <language>spa</language>         <statement/>         <statement2/>         <statement3/>         <size/>         <attribute>a</attribute>         <containment/>         <attribute>b</attribute>         <containment/>     </test> 

there no parent tags in xml.

for eng need update statement, statement2, , statement3.

same case spa , fra. data going different. means statement spa , fra carry different data.

i have related data me, fetched in datatable in vb.net code, unable differentiate between statement tag spa , fra.

is there way can update statement tag related spa different data , statement tag related fra different data?

i have tried getelementsbytagname method, updates of tags same data, , retains last entry.

please let me know if have solution.

try following code

private sub button1_click(sender system.object, e system.eventargs) handles button1.click     dim xdocument1 xdocument =         <?xml version="1.0" encoding="utf-8"?>         <test xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">             <language>eng</language>             <statement/>             <statement2/>             <statement3/>             <size/>             <language>fra</language>             <statement/>             <statement2/>             <statement3/>             <size/>             <language>spa</language>             <statement/>             <statement2/>             <statement3/>             <size/>             <attribute>a</attribute>             <containment/>             <attribute>b</attribute>             <containment/>         </test>      dim integer      = 0 xdocument1.descendants("language").count - 1         dim xlanguage1 xelement = xdocument1.descendants("language").elementat(i)         dim xstatement1 xelement = xdocument1.descendants("statement").elementat(i)         dim xstatement2 xelement = xdocument1.descendants("statement2").elementat(i)         dim xstatement3 xelement = xdocument1.descendants("statement3").elementat(i)          select case xlanguage1.value             case "eng"                 xstatement1.value = "statement1 english"                 xstatement2.value = "statement2 english"                 xstatement3.value = "statement3 english"             case "fra"                 xstatement1.value = "statement1 french"                 xstatement2.value = "statement2 french"                 xstatement3.value = "statement3 french"             case "spa"                 xstatement1.value = "statement1 spanish"                 xstatement2.value = "statement2 spanish"                 xstatement3.value = "statement3 spanish"         end select     next      msgbox(xdocument1.tostring) end sub 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -