Dataset.readxml()仅添加出现一次的标记

时间:2014-12-03 19:45:10

标签: c# xml dataset

我已在c#中编写此代码以读取xml文件(我将在底部提供一个代码段)

代码:

    string filePath = "movies.xml";
    movieDataSet.ReadXml(filePath, XmlReadMode.InferTypedSchema);
    movieList.DataSource = movieDataSet;
    movieList.DataMember = "movie";

XML文件:

<movielist>
<movie>
    <title>Adventures of Casanova </title>
    <year>1948</year>
    <length>83 min</length>
    <certification>Approved</certification>
    <director>Roberto Gavaldn</director>
    <rating>1</rating>
    <genre>Action</genre>
    <genre>Adventure</genre>
    <genre>History</genre>
    <genre>Romance</genre>
    <genre>War</genre>
    <actor>Arturo de C  rdova</actor>
    <actor>Lucille Bremer</actor>
    <actor>Turhan Bey</actor>
    <actor>John Sutton</actor>
    <actor>George Tobias</actor>
</movie>
<movie>
    <title>Amazon Quest </title>
    <year>1954</year>
    <length>75 min</length>
    <director>Steve Sekely</director>
    <rating>7</rating>
    <genre>Action</genre>
    <genre>Drama</genre>
    <actor>Tom Neal</actor>
    <actor>Carole Mathews</actor>
    <actor>Carole Donne</actor>
    <actor>Don Zelaya</actor>
    <actor>Ralph Graves</actor>
</movie>
<movie>
    <title>American Ninja 3: Blood Hunt </title>
    <year>1989</year>
    <length>89 min</length>
    <certification>R</certification>
    <director>Cedric Sundstrom</director>
    <rating>7</rating>
    <genre>Action</genre>
    <genre>Drama</genre>
    <actor>David Bradley</actor>
    <actor>Steve James</actor>
    <actor>Marjoe Gortner</actor>
    <actor>Michele B. Chan</actor>
    <actor>Yehuda Efroni</actor>
</movie>
</movielist>

我注意到唯一正在阅读的标签是电影中出现的标题,年份,长度,认证,导演,评级。我能做错什么?我尝试过不同的XmlReadMode,而InferTypedSchema似乎是最接近解决我将xml数据添加到数据集的问题的那个

0 个答案:

没有答案