Convert a string to XML

Hi

I want to save the address in the database using XMLString.
LIKE FIRST NAME,LASTNAME,ADDRESS,CITY ETC ARE different textboxes on the aspx page.
i want to concatenate the value of all these in a xmlstring and want to save it to database like

<Address>
<Bvin /><NickName /><FirstName /><MiddleInitial /><LastName /><Company />
<Line1 /><Line2 /><Line3 /><City /><RegionName /><RegionBvin /><PostalCode />
</Address>

Using C#.

Thanks
ASPNET_8Asked:
Who is Participating?
 
Didier VallySystems Engineer and Finance AnalystCommented:
I suggest you use the XmlTextWriter class from Microsoft :
http://msdn.microsoft.com/fr-fr/library/system.xml.xmltextwriter.aspx

0
 
guveraCommented:
0
 
Plk_In_EECommented:
Hi there,
This can be accomplished as below, sample code snippet.

DataSet reportData = new DataSet();
reportData.ReadXml(Server.MapPath(”report.xml”));

SqlConnection connection = new SqlConnection(”CONNECTION STRING”);
SqlBulkCopy sbc = new SqlBulkCopy(connection);
sbc.DestinationTableName = “report_table”;
       
//if your DB col names don’t match your XML element names 100%
//then relate the source XML elements (1st param) with the destination DB cols
sbc.ColumnMappings.Add(”campaign”, “campaign_id”);
sbc.ColumnMappings.Add(”cost”, “cost_USD”);
connection.Open();

//table 4 is the main table in this dataset
sbc.WriteToServer(reportData.Tables[4]);
connection.Close();
//remove the xml file
---
0
 
ASPNET_8Author Commented:
OK
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.