asp.net - System.argumentException while inserting xml node into document -


i trying insert xml node node in xml document continuously getting "system.argumentexception" whenever test it. have tried several ways of inserting node cannot work out how fix it.

here's code:

dim content string = "<name>" + songname + "</name><artist>" + songartist + "</artist><album>" +   songalbum + "</album>"             dim doc new xmldocument             doc.load(getpath())             dim xmlnode = doc.createelement("song")             i.innerxml = content              try                 list.appendchild(i)             catch              end try              doc.save(getpath())             return true         end if      end if 

i know stepping , using try catch statement error "the node inserted different document context." , occurs @ "list.appendchild(i)" line in code.

could offer suggestions fix error please?

edit

i tried using doc.appendchild() instead of list.appendchild() , got error message (shown in comments).

looking @ previous method inserted node document used "root.appendchild()" pretty sure list right variable use

the issue understand it, need import document first, append it. please see sample below.

http://www.dailyfreecode.com/forum/node-inserted-different-document-40.aspx


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -