I have a DataRow with columns col1 and col2. Each column has a value: val1 and val2 respectively. How can I turn this into an xml string using C#?
For the DataRow mentioned above I’d like the following string:
<col1>val1</col1><col2>val2</col2>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Technically correct, but I would council against this, largely as you have no control over the XML outputted.
I would loop through the rows of the table and use the System.Linq.XML classes to properly format your XML (or if you’re feeling more perverse, try XMLDocument and related classes)