Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Question about Convert XML to DataTable

Question about Convert XML to DataTable

Scheduled Pinned Locked Moved XML / XSL
xmlquestiondatabasehelpannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leejs413
    wrote on last edited by
    #1

    I am programming a movie info collect tool. I think store all data with XML is OK. Here is the MovieDataXML

    <?xml version="1.0" encoding="utf-8" ?>
    <Data>
    <Movie>
    <ChineseName>aa</ChineseName>
    <EnglishName>aa</EnglishName>
    <Year>aa</Year>
    <Area>aa</Area>
    <Type>aa</Type>
    <Language>aa</Language>
    <Subtitle>aa</Subtitle>
    <IMDB>aa</IMDB>
    <Resolution>aa</Resolution>
    <Director>aa</Director>
    <Actors>aa</Actors>
    <Introduction>aa</Introduction>
    <BelongTo>aa</BelongTo>
    <DiscNumber>aa</DiscNumber>
    </Movie>
    </Data>

    And when I try to read the data.

    //clsXmlHandler is a class to read the xml data
    ClassXMLHandler clsXmlHandler = new ClassXMLHandler();
    string strMovieData = "Data";
    XmlNode xNodeMovieData = clsXmlHandler.MovieDataDocument.SelectSingleNode(strMovieData);
    XmlNodeReader xReader = new XmlNodeReader(xNodeMovieData);

    Here is the problem If I read XML data by DataTable There will be a Exception "DataTable does not support schema inference from Xml", If I create this DataTable schema manually,there is no data in that DataTable.

    DataTable dtMovieData = new DataTable();
    dtMovieData.ReadXml(xReader);

    But I found it is OK if I use DataSet instead of DataTable

    DataSet ds = new DataSet();
    ds.ReadXml(xReader);

    I don't know why.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups