C# 使用C将记录添加到关系XML
我有一个XML和XSD,我想用Dataset向trck表添加一条记录,我也在编写代码,但需要trackListrow。。。 我怎么办C# 使用C将记录添加到关系XML,c#,xml,xsd,dataset,C#,Xml,Xsd,Dataset,我有一个XML和XSD,我想用Dataset向trck表添加一条记录,我也在编写代码,但需要trackListrow。。。 我怎么办 playListDS rec = new playListDS(); if(File.Exists(Server.MapPath("~/playlist.xml"))) rec.ReadXml(Server.MapPath("~/playlist.xml")); int id =
playListDS rec = new playListDS();
if(File.Exists(Server.MapPath("~/playlist.xml")))
rec.ReadXml(Server.MapPath("~/playlist.xml"));
int id = int.Parse(rec.track.Rows[rec.track.Rows.Count - 1][0].ToString()) + 1;
if (ViewState["Filename"] != null && ViewState["Cover"] != null)
{
playListDS.trackListRow row = new playListDS.trackListRow();
rec.track.AddtrackRow(id.ToString(), "mp3/" + ViewState["Filename"].ToString(), txtartist.Text,
txtalbum.Text, txttitle.Text,
txtannotation.Text, txtduration.Text, "mp3/cover" + ViewState["Cover"].ToString(),
txtinfo.Text, txtlink.Text);
你的意思是这样的:
playListDS rec = new playListDS();
if(File.Exists(Server.MapPath("~/playlist.xml")))
{
rec.ReadXml(Server.MapPath("~/playlist.xml"));
}
int id = int.Parse(rec.track.Rows[rec.track.Rows.Count - 1][0].ToString()) + 1;
if (ViewState["Filename"] != null && ViewState["Cover"] != null)
{
playListDS.trackListRow row = rec.track.AddtrackRow(id.ToString(), "mp3/" +
ViewState["Filename"].ToString(), txtartist.Text,
txtalbum.Text, txttitle.Text,
txtannotation.Text, txtduration.Text, "mp3/cover" +
ViewState["Cover"].ToString(),
txtinfo.Text, txtlink.Text);
}
您所需要的只是新添加的行?如果是这样的话,您将从AddtrackRow方法中获得新行。是的,但是这样操作xml。Dew mp3播放器看不到两个曲目列表表
<trackList>
<track>
<FileID>6</FileID>
<location>mp3/Gomez - See The World-1.mp3</location>
<creator>Gomez</creator>
<album>How We Operate</album>
<title>See the World</title>
<annotation>Buraya kendi yorumun gelicek boş kalabilir</annotation>
<duration>243670</duration>
<image>mp3/coverChrysanthemum.jpg</image>
<info />
<link>Grubun bi sitesi fln varsa buraya yazabilisin yoksa beni sil</link>
</track>
</trackList>
<trackList>
<track>
<FileID>8</FileID>
<location>mp3/Archives - Sleepdriving.mp3</location>
<creator>Grand Archives</creator>
<album>KEXP</album>
<title>Sleepdriving</title>
<annotation>Buraya kendi yorumun gelicek boş kalabilir</annotation>
<duration>323562</duration>
<image>mp3/coverDesert.jpg</image>
<info>PITCHFORK / FORKCAST
http://pitchforkmedia.com</info>
<link>Grubun bi sitesi fln varsa buraya yazabilisin yoksa beni sil</link>
</track>
</trackList>
您可能希望编辑原始帖子,而不是将您的回复作为答案发布。看看如果我没有得到一个好答案怎么办?在常见问题解答中。
playListDS rec = new playListDS();
if(File.Exists(Server.MapPath("~/playlist.xml")))
{
rec.ReadXml(Server.MapPath("~/playlist.xml"));
}
int id = int.Parse(rec.track.Rows[rec.track.Rows.Count - 1][0].ToString()) + 1;
if (ViewState["Filename"] != null && ViewState["Cover"] != null)
{
playListDS.trackListRow row = rec.track.AddtrackRow(id.ToString(), "mp3/" +
ViewState["Filename"].ToString(), txtartist.Text,
txtalbum.Text, txttitle.Text,
txtannotation.Text, txtduration.Text, "mp3/cover" +
ViewState["Cover"].ToString(),
txtinfo.Text, txtlink.Text);
}
<trackList>
<track>
<FileID>6</FileID>
<location>mp3/Gomez - See The World-1.mp3</location>
<creator>Gomez</creator>
<album>How We Operate</album>
<title>See the World</title>
<annotation>Buraya kendi yorumun gelicek boş kalabilir</annotation>
<duration>243670</duration>
<image>mp3/coverChrysanthemum.jpg</image>
<info />
<link>Grubun bi sitesi fln varsa buraya yazabilisin yoksa beni sil</link>
</track>
</trackList>
<trackList>
<track>
<FileID>8</FileID>
<location>mp3/Archives - Sleepdriving.mp3</location>
<creator>Grand Archives</creator>
<album>KEXP</album>
<title>Sleepdriving</title>
<annotation>Buraya kendi yorumun gelicek boş kalabilir</annotation>
<duration>323562</duration>
<image>mp3/coverDesert.jpg</image>
<info>PITCHFORK / FORKCAST
http://pitchforkmedia.com</info>
<link>Grubun bi sitesi fln varsa buraya yazabilisin yoksa beni sil</link>
</track>
</trackList>