Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:30:16+00:00 2026-06-15T05:30:16+00:00

I have a text string containing XML data (though it has no header info)

  • 0

I have a text string containing XML data (though it has no header info) and I am attempting to populate a DataTable containing its elements. I am not receiving any error messages, however my DataTable contains 0 rows following the .ReadXml command. The Xml is as follows:

<items>
 <item>
  <Date>05-Feb-2008</Date>
  <User>Unknown</User>
  <Comment>Due date moved</Comment>
  <Restricted>True</Restricted>
 </item>
 <item>
  <Date>07-Nov-2008</Date>
  <User>Unknown</User>
  <Comment>Priority increased. Due date moved to end Oct</Comment>
  <Restricted>False</Restricted>
 </item>
</items>

And my code to create the DataTable is as follows:

Stream xmlStream = new MemoryStream();
StreamWriter writer = new StreamWriter(xmlStream);
string xml = (string)row["XmlComments"];
writer.Write(xml);
writer.Flush();
xmlStream.Position = 0;

DataTable xmlComments = new DataTable();

xmlComments.Columns.Add("User", typeof(string));
xmlComments.Columns.Add("Date", typeof(DateTime));
xmlComments.Columns.Add("Comment", typeof(string));
xmlComments.Columns.Add("OSG_Only", typeof(string));

xmlComments.ReadXml(xmlStream);

Could anyone shed any light on what I’m missing here?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:30:19+00:00Added an answer on June 15, 2026 at 5:30 am

    This should work

    DataTable xmlComments = new DataTable();
    
    xmlComments.TableName = "item"; //<---- Added
    xmlComments.Columns.Add("User", typeof(string));
    xmlComments.Columns.Add("Date", typeof(string)); //<---- Type changed
    xmlComments.Columns.Add("Comment", typeof(string));
    xmlComments.Columns.Add("Restricted", typeof(string)); //<---- Column name changed
    
    xmlComments.ReadXml(xmlStream);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's my situation. I have a string containing XML data: <tag> <anotherTag> data </anotherTag>
I have a string headerText, which containing text ABC (2-8 Days). How can truncate
I have a text string that has been doctored to be web safe URLs
I have a text string with HTML embedded in it. It also has CRs
I have an XML file containing seed data that I'm trying to load into
I have a variable string text containing lets say ABCDEFGHIJKL. I want to trim
I have an XML file containing some scientific text that I want to display
I have got an xml file containing some attributes like <string name=my/ attribute optional=true>
I have a string containing text and HTML. I want to remove or otherwise
I have a text file containing strings to encrypt. These strings are indicated by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.