table to xml record c# -


i need store on sql server db many records in same column , use xml field this.on backend have code reads/writes xml records , inserts data in table.the table of variable size. have problem in reading fields table , insert them xml variable. need :

<bigtag> <smalltagname1>  something</smalltagname1> <smalltagname2>  thanksforanswering</smalltagname2> <smalltagname3>  youareawesome</smalltagname3> </bigtag> 

the table is:

smalltagtable[] = {something,thanksforanswering,youareawesome,....} 

here code:

xelement widgetliste1 = null;  widgetliste1 = new xelement("bigtag"  );  string smalltagname = "smalltag "; string smalltagdata;  for(int i=0;i<smalltagtable.length; i++ ) {     smalltagname = "smalltagname " + i;     smalltagdata = smalltagtable[i];     widgetliste1.add(new xelement(smalltagname.tostring(),smalltagdata.tostring() )); }  string a2 = widgetliste1.tostring(); 

the problem code hits error :

the ' ' character, hexadecimal value 0x20, cannot included in name. on line :

widgetliste1.add(new xelement(smalltagname.tostring(),smalltagdata.tostring() )); 

i post make sure answer appears clearly. credits go panagiotis kanavos. problem there space in tag of xml. instead of being :

 <smalltag 1> </smalltag 1>  

it should

<smalltag1> something</smalltag1> 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -