How to create an XML <ABC Name="XYZ" Place="DEF" /> in C# -


iam trying create xml in particular format

format needed

<rowdata> <row name="abc" place="def"/> </rowdata> 

currently format getting as

<rowdata>  <row>name="abc" place="def" </row> </rowdata> 

code

xmlwritersettings wsettings = new xmlwritersettings(); wsettings.indent = true; wsettings.conformancelevel = conformancelevel.fragment; wsettings.omitxmldeclaration = true; memorystream ms = new memorystream(); xmlwriter xw = xmlwriter.create(ms, wsettings); xw.writestartelement("rowdata");  (int = 0; < dt.rows.count; i++) {     xw.writestartelement("row");    xw.writestring("name=" + "''" + dts1.rows[i]["name"].tostring() + "''");    xw.writestring("place=" + "''" + dts1.rows[i]["place"].tostring() + "''");    xw.writeendelement(); }  

what change have getting output in below format

<rowdata> <row name="abc" place="def"/> </rowdata> 

what need writeattributestring method.

writer.writeattributestring("name", dts1.rows[i]["name"].tostring());  writer.writeattributestring("place", dts1.rows[i]["place"].tostring());  

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -